2023-05-29 07:44:08 +07:00
|
|
|
#!/usr/bin/env node
|
2023-07-23 07:27:41 +07:00
|
|
|
import yargs from "yargs"
|
|
|
|
import { hideBin } from "yargs/helpers"
|
2023-08-28 05:59:51 +07:00
|
|
|
import {
|
|
|
|
handleBuild,
|
|
|
|
handleCreate,
|
|
|
|
handleUpdate,
|
|
|
|
handleRestore,
|
|
|
|
handleSync,
|
|
|
|
} from "./cli/handlers.js"
|
|
|
|
import { CommonArgv, BuildArgv, CreateArgv, SyncArgv } from "./cli/args.js"
|
|
|
|
import { version } from "./cli/constants.js"
|
2023-08-03 13:29:28 +07:00
|
|
|
|
2023-05-30 22:02:20 +07:00
|
|
|
yargs(hideBin(process.argv))
|
|
|
|
.scriptName("quartz")
|
|
|
|
.version(version)
|
2023-07-23 07:27:41 +07:00
|
|
|
.usage("$0 <cmd> [args]")
|
2023-08-27 03:21:44 +07:00
|
|
|
.command("create", "Initialize Quartz", CreateArgv, async (argv) => {
|
2023-08-28 05:59:51 +07:00
|
|
|
await handleCreate(argv)
|
2023-07-05 14:16:06 +07:00
|
|
|
})
|
2023-07-23 07:27:41 +07:00
|
|
|
.command("update", "Get the latest Quartz updates", CommonArgv, async (argv) => {
|
2023-08-28 05:59:51 +07:00
|
|
|
await handleUpdate(argv)
|
2023-07-17 00:39:35 +07:00
|
|
|
})
|
2023-08-18 11:24:41 +07:00
|
|
|
.command(
|
|
|
|
"restore",
|
|
|
|
"Try to restore your content folder from the cache",
|
|
|
|
CommonArgv,
|
|
|
|
async (argv) => {
|
2023-08-28 05:59:51 +07:00
|
|
|
await handleRestore(argv)
|
2023-08-18 11:24:41 +07:00
|
|
|
},
|
|
|
|
)
|
2023-07-23 07:27:41 +07:00
|
|
|
.command("sync", "Sync your Quartz to and from GitHub.", SyncArgv, async (argv) => {
|
2023-08-28 05:59:51 +07:00
|
|
|
await handleSync(argv)
|
2023-07-17 00:39:35 +07:00
|
|
|
})
|
2023-07-23 07:27:41 +07:00
|
|
|
.command("build", "Build Quartz into a bundle of static HTML files", BuildArgv, async (argv) => {
|
2023-08-28 05:59:51 +07:00
|
|
|
await handleBuild(argv)
|
2023-05-30 22:02:20 +07:00
|
|
|
})
|
|
|
|
.showHelpOnFail(false)
|
|
|
|
.help()
|
|
|
|
.strict()
|
2023-07-23 07:27:41 +07:00
|
|
|
.demandCommand().argv
|