/ quartz / bootstrap-cli.mjs
bootstrap-cli.mjs
 1  #!/usr/bin/env -S node --no-deprecation
 2  import yargs from "yargs"
 3  import { hideBin } from "yargs/helpers"
 4  import {
 5    handleBuild,
 6    handleCreate,
 7    handleUpdate,
 8    handleRestore,
 9    handleSync,
10  } from "./cli/handlers.js"
11  import { CommonArgv, BuildArgv, CreateArgv, SyncArgv } from "./cli/args.js"
12  import { version } from "./cli/constants.js"
13  
14  yargs(hideBin(process.argv))
15    .scriptName("quartz")
16    .version(version)
17    .usage("$0 <cmd> [args]")
18    .command("create", "Initialize Quartz", CreateArgv, async (argv) => {
19      await handleCreate(argv)
20    })
21    .command("update", "Get the latest Quartz updates", CommonArgv, async (argv) => {
22      await handleUpdate(argv)
23    })
24    .command(
25      "restore",
26      "Try to restore your content folder from the cache",
27      CommonArgv,
28      async (argv) => {
29        await handleRestore(argv)
30      },
31    )
32    .command("sync", "Sync your Quartz to and from GitHub.", SyncArgv, async (argv) => {
33      await handleSync(argv)
34    })
35    .command("build", "Build Quartz into a bundle of static HTML files", BuildArgv, async (argv) => {
36      await handleBuild(argv)
37    })
38    .showHelpOnFail(false)
39    .help()
40    .strict()
41    .demandCommand().argv