Skip to content

Commit 9bb09f9

Browse files
committed
feat: added skip banner flag to init command
1 parent a9a3d42 commit 9bb09f9

8 files changed

Lines changed: 20 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
"deploy": "npm run pkg && npm run notarize && npm run upload",
146146
"prepublishOnly": "npm run build"
147147
},
148-
"version": "1.1.0-beta.1",
148+
"version": "1.1.0-beta.3",
149149
"bugs": "https://github.com/codifycli/codify/issues",
150150
"keywords": [
151151
"oclif",

src/commands/init.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ For more information, visit: https://codifycli.com/docs/commands/init`
2121
includeSensitive: Flags.boolean({
2222
description: 'Include sensitive resources in the generated configs.',
2323
}),
24+
skipBanner: Flags.boolean({
25+
description: 'Skip the initial confirmation prompt.',
26+
}),
2427
}
2528

2629
static override examples = [
@@ -34,6 +37,7 @@ For more information, visit: https://codifycli.com/docs/commands/init`
3437
verbosityLevel: flags.debug ? 3 : 0,
3538
path: flags.path,
3639
includeSensitive: flags.includeSensitive,
40+
skipBanner: flags.skipBanner,
3741
},this.reporter);
3842

3943
process.exit(0)

src/orchestrators/init.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ export interface InitArgs {
1616
path?: string;
1717
verbosityLevel?: number;
1818
includeSensitive?: boolean;
19+
skipBanner?: boolean;
1920
}
2021

2122
export const InitializeOrchestrator = {
2223

2324
async run(args: InitArgs, reporter: Reporter) {
24-
await reporter.displayInitBanner()
25+
await reporter.displayInitBanner(args.skipBanner)
2526

2627
ctx.processStarted(ProcessName.INIT)
2728
await reporter.displayProgress();

src/ui/reporters/default-reporter.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ export class DefaultReporter implements Reporter {
100100
await this.updateRenderState(previousRenderState.status, previousRenderState.data);
101101
}
102102

103-
async displayInitBanner(): Promise<void> {
103+
async displayInitBanner(skipConfirmation?: boolean): Promise<void> {
104+
if (skipConfirmation) {
105+
await this.updateRenderState(RenderStatus.DISPLAY_INIT_BANNER);
106+
return;
107+
}
108+
104109
await this.updateStateAndAwaitEvent<boolean>(
105110
() => this.updateRenderState(RenderStatus.DISPLAY_INIT_BANNER),
106111
RenderEvent.PROMPT_RESULT,

src/ui/reporters/json-reporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class JsonReporter implements Reporter {
2020
${message}`)
2121
}
2222

23-
async displayInitBanner(): Promise<void> {
23+
async displayInitBanner(_skipConfirmation?: boolean): Promise<void> {
2424
}
2525

2626
async displayProgress(): Promise<void> {

src/ui/reporters/plain-reporter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,14 @@ export class PlainReporter implements Reporter {
145145
return undefined;
146146
}
147147

148-
async displayInitBanner(): Promise<void> {
148+
async displayInitBanner(skipConfirmation?: boolean): Promise<void> {
149149
ctx.log(`Codify is a configuration-as-code tool that helps you setup and manage your system.
150150
Use this init flow to get started quickly with Codify.
151151
`);
152152

153-
await this.promptConfirmation('Codify will scan your system for any supported programs or settings and automatically generate configs for you.')
153+
if (!skipConfirmation) {
154+
await this.promptConfirmation('Codify will scan your system for any supported programs or settings and automatically generate configs for you.')
155+
}
154156
}
155157

156158
async promptConfirmation(message: string): Promise<boolean> {

src/ui/reporters/reporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export interface Reporter {
5454

5555
displayPlan(plan: Plan): Promise<void>
5656

57-
displayInitBanner(): Promise<void>
57+
displayInitBanner(skipConfirmation?: boolean): Promise<void>
5858

5959
displayProgress(): Promise<void>;
6060

src/ui/reporters/stub-reporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { PromptType, Reporter } from './reporter.js';
1111
export class StubReporter implements Reporter {
1212
silent: boolean = true;
1313
async displayPlan(): Promise<void> {}
14-
async displayInitBanner(): Promise<void> {}
14+
async displayInitBanner(_skipConfirmation?: boolean): Promise<void> {}
1515
async displayProgress(): Promise<void> {}
1616
async hide(): Promise<void> {}
1717
async promptInitResultSelection(availableTypes: string[]): Promise<string[]> { return []; }

0 commit comments

Comments
 (0)