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

@ -21,7 +21,7 @@ worm-scraper --help
If this outputs some help documentation, then the installation process went smoothly. You can move on to assemble the eBook by typing If this outputs some help documentation, then the installation process went smoothly. You can move on to assemble the eBook by typing
```bash ```bash
worm-scraper download convert scaffold zip worm-scraper
``` ```
This will take a while, but will eventually produce a `Worm.epub` file! This will take a while, but will eventually produce a `Worm.epub` file!
@ -29,7 +29,7 @@ This will take a while, but will eventually produce a `Worm.epub` file!
If you'd like to get _Ward_ instead of _Worm_, use `--book=ward`, e.g. If you'd like to get _Ward_ instead of _Worm_, use `--book=ward`, e.g.
```bash ```bash
worm-scraper download convert scaffold zip --book=ward worm-scraper --book=ward
``` ```
## EPUB vs. other formats ## EPUB vs. other formats

View file

@ -16,7 +16,8 @@ const OUTPUT_DEFAULT = "(Book name).epub";
const argv = yargs const argv = yargs
.usage(`${packageJson.description}\n\n${packageJson.name} [<command1> [<command2> [<command3> ...]]]\n\n` + .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("download", "download all chapters into the cache")
.command("convert", "convert the raw HTML into cleaned-up ebook chapters") .command("convert", "convert the raw HTML into cleaned-up ebook chapters")
.command("scaffold", "assemble the table of contents, etc.") .command("scaffold", "assemble the table of contents, etc.")
@ -58,7 +59,6 @@ const argv = yargs
requiresArg: true, requiresArg: true,
global: true global: true
}) })
.demandCommand(1) // TODO remove and allow all
.recommendCommands() .recommendCommands()
.help() .help()
.version() .version()
@ -77,6 +77,10 @@ const chaptersPath = path.resolve(contentPath, "chapters");
const commands = []; const commands = [];
if (argv._.length === 0) {
argv._ = ["download", "convert", "scaffold", "zip"];
}
if (argv._.includes("download")) { if (argv._.includes("download")) {
const startURL = books[argv.book].startURL; const startURL = books[argv.book].startURL;
commands.push(() => download(startURL, cachePath, manifestPath)); commands.push(() => download(startURL, cachePath, manifestPath));