#!/usr/bin/env node const path = require("path"); const fs = require("vinyl-fs"); const map = require("map-stream"); const tokenize = require("./tokenize"); const toHTML = require("./to-html"); require("yargs") .scriptName("gmi-web") .command( "$0 [--no-css] [files..]", "Convert .gmi to .html. See gmi-web(1) for more details.", (yargs) => yargs .positional("files", { describe: ".gmi files to convert to .html", }) .required("files", true) .option("css", { type: "boolean", default: true, description: "Toggle inclusion of gmi.css.", }), (argv) => { fs.src(argv.files) .pipe(map(tokenize)) .pipe(map(toHTML({ css: argv["css"] }))) .pipe(fs.dest((file) => path.dirname(file.path))); } ) .help().argv; function log(file, cb) { console.log(file.path, file.contents ? file.contents.toString("utf8") : ""); cb(null, file); }