Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
fix boolean options wizard mode
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 committed Nov 28, 2023
1 parent ee21343 commit 585b602
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/internal/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ const wizardInternal = (
)
}
case "SubcommandWizard": {
console.log(self.parent)
return Effect.zipWith(
loop(self.parent),
loop(self.child),
Expand Down
3 changes: 3 additions & 0 deletions src/internal/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,9 @@ const wizardInternal = (self: Instruction, config: CliConfig.CliConfig): Effect.
)
}
case "WithDefault": {
if (isBoolInternal(self.options as Instruction)) {
return wizardInternal(self.options as Instruction, config)
}
const defaultHelp = InternalHelpDoc.p(`This option is optional - use the default?`)
const message = pipe(
wizardHeader,
Expand Down
5 changes: 3 additions & 2 deletions src/internal/primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,13 @@ const wizardInternal = (self: Instruction, help: HelpDoc.HelpDoc): Prompt.Prompt
case "Bool": {
const primitiveHelp = InternalHelpDoc.p("Select true or false")
const message = InternalHelpDoc.sequence(help, primitiveHelp)
const initial = Option.getOrElse(self.defaultValue, () => false)
return InternalTogglePrompt.toggle({
message: InternalHelpDoc.toAnsiText(message).trimEnd(),
initial: Option.getOrElse(self.defaultValue, () => false),
initial,
active: "true",
inactive: "false"
}).pipe(InternalPrompt.map((bool) => `${bool}`))
}).pipe(InternalPrompt.map((bool) => bool))
}
case "Choice": {
const primitiveHelp = InternalHelpDoc.p("Select one of the following choices")
Expand Down

0 comments on commit 585b602

Please sign in to comment.