Allow running with no commands

This commit is contained in:
Domenic Denicola 2020-12-26 17:43:42 -05:00
commit 0be098ff16
2 changed files with 8 additions and 4 deletions

View file

@ -16,7 +16,8 @@ const OUTPUT_DEFAULT = "(Book name).epub";
const argv = yargs
.usage(`${packageJson.description}\n\n${packageJson.name} [<command1> [<command2> [<command3> ...]]]\n\n` +
"Each command will fail if the previously-listed one has not yet been run (with matching options).")
"Each command will fail if the previously-listed one has not yet been run (with matching options).\n\n" +
"Running with no commands is equivalent to running download convert scaffold zip.")
.command("download", "download all chapters into the cache")
.command("convert", "convert the raw HTML into cleaned-up ebook chapters")
.command("scaffold", "assemble the table of contents, etc.")
@ -58,7 +59,6 @@ const argv = yargs
requiresArg: true,
global: true
})
.demandCommand(1) // TODO remove and allow all
.recommendCommands()
.help()
.version()
@ -77,6 +77,10 @@ const chaptersPath = path.resolve(contentPath, "chapters");
const commands = [];
if (argv._.length === 0) {
argv._ = ["download", "convert", "scaffold", "zip"];
}
if (argv._.includes("download")) {
const startURL = books[argv.book].startURL;
commands.push(() => download(startURL, cachePath, manifestPath));