update --help

This commit is contained in:
Talon Poole 2021-02-19 19:52:02 +00:00
parent 4a81c7248e
commit d11e241131
2 changed files with 46 additions and 50 deletions

View file

@ -77,8 +77,21 @@ gmi-web [files..]
Convert text/gemini to text/html.
Core:
--body [boolean]
--html, --language, --lang [string]
--css
HTML:
--author [string]
--descriptions
Media:
--image [array]
--audio [array]
--video [array]
CSS:
--inline [boolean]
--foreground [default: "black"]
--background [default: "white"]
--body-width [default: "48rem"]
@ -115,21 +128,6 @@ CSS:
--quote-height [default: "1.25"]
--quote-style [default: "italic"]
Core:
--html, --language, --lang [string]
--body [boolean]
HTML:
--author [string]
--descriptions [number] [default: 0]
--css [default: "full"]
--dir [string] [choices: "rtl", "ltr"] [default: "ltr"]
Inline Media:
--image [array]
--audio [array]
--video [array]
Options:
--version Show version number [boolean]
--config Path to JSON config file

66
cli.js
View file

@ -24,10 +24,16 @@ const cli = yargs(process.argv.slice(2))
.options({
body: {
type: "boolean",
group: "Core:",
},
html: {
type: "string",
requiresArg: true,
group: "Core:",
},
css: {
requiresArg: true,
group: "Core:",
},
dir: {
type: "string",
@ -35,47 +41,45 @@ const cli = yargs(process.argv.slice(2))
choices: ["rtl", "ltr"],
default: "ltr",
requiresArg: true,
group: "HTML:",
},
author: {
type: "string",
requiresArg: true,
group: "HTML:",
},
descriptions: {
coerce: (arg) => {
return typeof arg === "number" ? arg : arg ? Infinity : 0;
},
},
css: {
default: "full",
requiresArg: true,
},
inline: {
type: "boolean",
hidden: true,
group: "CSS:",
},
image: {
type: "array",
requiresArg: true,
},
audio: {
type: "array",
requiresArg: true,
},
video: {
type: "array",
requiresArg: true,
coerce: (arg) => (typeof arg === "number" ? arg : arg ? Infinity : 0),
group: "HTML:",
},
charset: {
type: "string",
hidden: true,
default: "utf-8",
requiresArg: true,
group: "HTML:",
},
})
.group(["html", "body"], "Core:")
.group(["author", "descriptions", "css", "dir"], "HTML:")
.group(["image", "audio", "video"], "Inline Media:");
image: {
type: "array",
requiresArg: true,
group: "Media:",
},
audio: {
type: "array",
requiresArg: true,
group: "Media:",
},
video: {
type: "array",
requiresArg: true,
group: "Media:",
},
inline: {
type: "boolean",
hidden: true,
group: "CSS:",
},
});
const CSS_VARS = CSS.rootVariables(CSS.FULL);
Object.keys(CSS_VARS).map((key) => {
@ -94,12 +98,6 @@ const argv = cli
.showHelpOnFail(true)
.help().argv;
if (argv.inline && argv.css === "full") {
cli.showHelp();
console.error(`\n--inline is not compatible with --css full`);
cli.exit(1);
}
if (!argv.html && !argv.body) {
cli.showHelp();
console.error(`\nMissing required argument: --html or --body`);