gmi-web/cli.js

36 lines
1,000 B
JavaScript
Raw Normal View History

2021-01-28 06:16:46 +00:00
#!/usr/bin/env node
2021-01-28 21:03:30 +00:00
const path = require("path");
const fs = require("vinyl-fs");
const map = require("map-stream");
const tokenize = require("./tokenize");
2021-01-28 06:16:46 +00:00
require("yargs")
.scriptName("gmi-web")
.command(
2021-01-28 21:03:30 +00:00
"$0 [--no-css] [files..]",
"A bridge between Gemini and HTML. See gmi-web(1) for more details.",
(yargs) =>
yargs
.positional("files", {
describe: ".gmi files to convert to .html",
})
.required("files", true)
.option("no-css", {
type: "boolean",
description: "Do not include gmi.css in the rendered HTML markup.",
}),
2021-01-28 06:16:46 +00:00
(argv) => {
2021-01-28 21:03:30 +00:00
fs.src(argv.files).pipe(map(tokenize)).pipe(map(log));
//.pipe(fs.dest((file) => {
// const dest = path.dirname(file.path)
// console.log(file.path, dest)
// return dest
//}));
2021-01-28 06:16:46 +00:00
}
)
.help().argv;
2021-01-28 21:03:30 +00:00
function log(file, cb) {
console.log(file.path, file.contents ? file.contents.toString("utf8") : "");
cb(null, file);
}