Skip to content

Commit

Permalink
Merge pull request #64 from drumath2237/feature/#17-think-about-args
Browse files Browse the repository at this point in the history
think about command-line args
  • Loading branch information
drumath2237 committed Aug 13, 2024
2 parents c6e5848 + 161b773 commit 9be0f2e
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,43 @@ const mainCommand = defineCommand({
"A CLI for scaffolding Babylon.js web application project from templates!",
};
},
run: async () => {
const projectName = await consola.prompt("Project Name?", {
args: {
name: {
type: "string",
alias: ["n"],
description: "project name.",
valueHint: "project name",
required: false,
},
template: {
type: "string",
alias: ["t"],
description: "project template name. e.g.) simple-ts, library.",
valueHint: "template name",
required: false,
},
install: {
type: "boolean",
alias: ["i"],
description: "install dependencies after copying template.",
required: false,
valueHint: "true or false",
},
},
run: async ({ args }) => {
const settings = {
projectName: args.name,
templateDirName: args.template,
doInstall: args.install,
};

settings.projectName ??= await consola.prompt("Project Name?", {
type: "text",
default: "babylon-app",
placeholder: "babylon-app",
});

const templateDirName = await constructTemplateNameAsync(
settings.templateDirName ??= await constructTemplateNameAsync(
templates,
async ({ message, selections }) => {
const val = await consola.prompt(message, {
Expand All @@ -45,11 +74,12 @@ const mainCommand = defineCommand({
},
);

const doInstall = await consola.prompt("Install Dependencies?", {
settings.doInstall ??= await consola.prompt("Install Dependencies?", {
type: "confirm",
initial: false,
});

const { projectName, templateDirName, doInstall } = settings;
const githubRepoUrlBase = "gh:drumath2237/create-babylon-app/templates";
const { dir: appDir } = await downloadTemplate(
`${githubRepoUrlBase}/${templateDirName}`,
Expand Down

0 comments on commit 9be0f2e

Please sign in to comment.