#!/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 [--css] ", "Convert .gmi to .html. See gmi-web(1) for more details.", (yargs) => yargs .positional("files", { describe: "The *.gmi files to convert", }) .required("files", true) .option("images", { type: "boolean", default: false, description: "Include images", }) .option("audio", { type: "boolean", default: false, description: "Include audio", }) .option("video", { type: "boolean", default: false, description: "Include video", }) .option("silent", { alias: "s", type: "boolean", default: false, description: "No logging to stdout", }) .option("css", { type: "boolean", default: true, description: "Include gmi.css", }), (argv) => { fs.src(argv.files) .pipe(map(tokenize)) .pipe( map( toHTML({ css: argv.css, inline: { images: argv.images, audio: argv.audio, video: argv.video, }, silent: argv.silent, }) ) ) .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); }