fix --version

This commit is contained in:
Talon Poole 2021-02-25 18:17:38 +00:00
parent 7b2b6c5f0a
commit 7196999957
3 changed files with 12 additions and 8 deletions

14
cli.js
View file

@ -5,19 +5,18 @@ import fs from "vinyl-fs";
import yargs from "yargs";
import * as CSS from "./css.js";
import { streamHTML, toHTML } from "./html.js";
const pkg = JSON.parse(readFileSync(path.resolve("package.json"), "utf-8"));
const cli = yargs(process.argv.slice(2))
.config("config", function (path) {
return JSON.parse(readFileSync(path), "utf-8");
})
.scriptName("gmi-web")
.command("$0 [files..]", "Convert text/gemini to text/html.", (yargs) =>
.command("$0 [files..]", pkg.description, (yargs) =>
yargs
.example("$0 --body < doc.gmi")
.example("$0 --html en $(find ~/my-capsule -name '*.gmi')")
.example(
"$0 --foreground '#9EEBCF' --html en < doc.gmi"
)
.example("$0 --foreground '#9EEBCF' --html en < doc.gmi")
.example("$0 --image jpg --audio mp3 --image png --body < doc.gmi")
.epilog("See the gmi-web(1) man page for more information.")
)
@ -82,7 +81,11 @@ const cli = yargs(process.argv.slice(2))
});
const css =
yargs(process.argv.slice(2)).version(false).help(false).exitProcess(false).parse().css || "gmi-web.css";
yargs(process.argv.slice(2))
.version(false)
.help(false)
.exitProcess(false)
.parse().css || "gmi-web.css";
const CSS_VARS = CSS.rootVariables(CSS.load({ css }));
Object.keys(CSS_VARS).forEach((key) => {
cli.option(key, { default: CSS_VARS[key] });
@ -97,6 +100,7 @@ const argv = cli
.alias("html", "language")
.alias("html", "lang")
.showHelpOnFail(true)
.version(pkg.version)
.help().argv;
if (!argv.html && !argv.body) {

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "gmi-web-cli",
"version": "1.0.3-rc.4",
"version": "1.0.4-rc.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -1,7 +1,7 @@
{
"name": "gmi-web-cli",
"version": "1.0.3-rc.4",
"description": "A bridge between Gemini and HTML",
"version": "1.0.7-rc.4",
"description": "Convert text/gemini to text/html.",
"main": "html.js",
"type": "module",
"bin": {