import { cli, define } from "gunshi"; import { infoCommand } from "./commands/info"; import { listCommand } from "./commands/list"; import { subscribeCommand } from "./commands/subscribe"; import { sukebeiCommand } from "./commands/sukebei"; import { syncCommand } from "./commands/sync"; import { whatsNewCommand } from "./commands/whats-new"; import { ExitCodes, exitWith } from "./envelope"; const main = define({ name: "fc2cma", description: "FC2 Content Market Adult — unofficial CLI" }); export const startCli = async (): Promise => { const argv = process.argv.slice(2); // Bare `fc2cma` with no args: show help instead of silently exiting. if (argv.length === 0) argv.push("--help"); await cli(argv, main, { name: "fc2cma", description: "FC2 Content Market Adult — unofficial CLI", renderHeader: null, // TODO(upstream): gunshi's default validation-error path prints the // message and exits 0. Remove this override once upstream exits non-zero. // See: https://github.com/kazupon/gunshi renderValidationErrors: (_ctx, error) => { const msg = error.errors.map((e) => (e instanceof Error ? e.message : String(e))).join("\n"); exitWith(ExitCodes.USAGE, msg); }, subCommands: { subscribe: subscribeCommand, sync: syncCommand, list: listCommand, info: infoCommand, "whats-new": whatsNewCommand, sukebei: sukebeiCommand } }); };