Skip to content

Commit

Permalink
display a nicer message in the cli wizard when using Option (#2847)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardo-valero authored May 25, 2024
1 parent a7d5c61 commit 7000173
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-keys-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/cli": patch
---

display a nicer message in the cli wizard when using Option
15 changes: 13 additions & 2 deletions packages/cli/src/internal/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1431,8 +1431,19 @@ const wizardInternal = (self: Instruction, config: CliConfig.CliConfig): Effect.
return InternalSelectPrompt.select({
message: InternalHelpDoc.toAnsiText(message).trimEnd(),
choices: [
{ title: `Default ['${JSON.stringify(self.fallback)}']`, value: true },
{ title: "Custom", value: false }
{
title: "Yes",
value: true,
description: `use the default ${
Option.isOption(self.fallback)
? Option.match(self.fallback, {
onNone: () => "",
onSome: (a) => `(${JSON.stringify(a)})`
})
: `(${JSON.stringify(self.fallback)})`
}`
},
{ title: "No", value: false, description: "use a custom value" }
]
}).pipe(
Effect.zipLeft(Console.log()),
Expand Down

0 comments on commit 7000173

Please sign in to comment.