Skip to content

Commit

Permalink
Add defaults to flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Mar 14, 2024
1 parent c6ceb56 commit 6ae65ab
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ type SinglePackageAnswers = Pick<Manifest, "name" | "version" | "description" |
type UserAnswers = SinglePackageAnswers & Partial<TemplatePackageAnswers>;

interface CliCommandOptions extends CliGlobalOptions {
yes?: boolean;
force?: boolean;
template?: boolean;
yes: boolean;
force: boolean;
template: boolean;
}

export const init: CommandModule<CliGlobalOptions, CliCommandOptions> = {
Expand All @@ -87,17 +87,20 @@ export const init: CommandModule<CliGlobalOptions, CliCommandOptions> = {
alias: "y",
description:
"Answer yes or the default option to all initialization questions",
type: "boolean"
type: "boolean",
default: false
},
force: {
alias: "f",
description: "Overwrite previous project if necessary",
type: "boolean"
type: "boolean",
default: false
},
template: {
alias: "t",
description: "Initialize a template DAppNodePackage, for creating several package variants that have the same base structure.",
type: "boolean"
type: "boolean",
default: false
}
},
handler: async args => {
Expand Down Expand Up @@ -127,12 +130,10 @@ dappnodesdk build ${args.template && "--all_variants"}
export async function initHandler({
dir = defaultDir,
compose_file_name: composeFileName = defaultComposeFileName,
yes,
yes: useDefaults,
force,
template
template: templateMode
}: CliCommandOptions): Promise<Manifest> {
const templateMode = !!template;
const useDefaults = !!yes;
// shell outputs tend to include trailing spaces and new lines
const directoryName = await shell('echo "${PWD##*/}"');
const defaultName = getDnpName(directoryName);
Expand Down Expand Up @@ -170,7 +171,7 @@ export async function initHandler({

createPackageDirectories(dir, answers.variants || [], answers.variantsDir || defaultVariantsDir, templateMode);

writePackageFiles({ dir, answers, templateMode, force: !!force, rootManifest, rootCompose, composeFileName, serviceName });
writePackageFiles({ dir, answers, templateMode, force, rootManifest, rootCompose, composeFileName, serviceName });

return rootManifest;
}
Expand Down

0 comments on commit 6ae65ab

Please sign in to comment.