@common-grants/cli
Version:
The CommonGrants protocol CLI tool
30 lines (29 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.initCommand = initCommand;
const init_service_1 = require("./init-service");
const init_args_1 = require("./init-args");
const error_1 = require("../../utils/error");
function initCommand(program) {
const initService = new init_service_1.DefaultInitService();
program
.command("init")
.description("Initialize a new CommonGrants project")
.option("-t, --template <template>", "Use a specific template")
.option("-l, --list", "List available templates")
.action(async (options) => {
try {
if (options.list) {
const templates = await initService.listTemplates();
console.log("Available templates:");
templates.forEach((template) => console.log(`- ${template}`));
return;
}
const validatedOptions = init_args_1.InitCommandSchema.parse(options);
await initService.init(validatedOptions);
}
catch (error) {
(0, error_1.handleCommandError)(error);
}
});
}