You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CLI module in effect-smol has the same limitation as @effect/cli: boolean flags never consume a value, and text/choice options always require one. There's no way to define a flag that works both bare (--watch) and with an explicit value (--watch=until-done).
This is the same feature request as #6182, filed here for effect-smol / v4.
@schickling - which optional-value semantics make the most sense to you?
GNU-style: --watch uses the fallback and only --watch=until-done supplies a value (i.e. = is required)
argparse-style: also accept --watch until-done by consuming the next non-flag token
I would recommend the GNU-style semantics. They match your examples and avoid ambiguously consuming positional arguments or subcommands, such as --watch build. Also, the CLI's lexer already distinguishes bare and inline values, so this would be simpler and more deterministic.
@IMax153 I have the GNU-style version you suggested working on v4 effect/cli, if it's useful. Since the issue is assigned to you, are you OK with me opening a PR for it?
The shape:
constwatch=Flag.Literals("watch",["first-failure","until-done"]).pipe(Flag.withOptionalValue("first-failure"),Flag.optional)// --watch -> Some("first-failure")// --watch=until-done -> Some("until-done")// -w / -w=until-done -> same, through the alias// (absent) -> None// --watch build -> Some("first-failure"), "build" stays a positional / subcommand
The value only comes after =. A bare flag never consumes the next token.
The value given to withOptionalValue is the raw string, parsed and validated like a typed --watch=<value>. So it works under Flag.map, Flag.withDefault, choices and so on.
Help shows --watch, -w [=choice]. The wizard writes the value inline. Shell completions stop expecting a separate value word after these flags; zsh also completes --watch=<TAB>.
Activity
IMax153 commentedon Jul 15, 2026
@schickling - which optional-value semantics make the most sense to you?
--watchuses the fallback and only--watch=until-donesupplies a value (i.e.=is required)--watch until-doneby consuming the next non-flag tokenI would recommend the GNU-style semantics. They match your examples and avoid ambiguously consuming positional arguments or subcommands, such as
--watch build. Also, the CLI's lexer already distinguishes bare and inline values, so this would be simpler and more deterministic.jayhemnani9910 commentedon Oct 13, 2026
@IMax153 I have the GNU-style version you suggested working on v4
effect/cli, if it's useful. Since the issue is assigned to you, are you OK with me opening a PR for it?The shape:
=. A bare flag never consumes the next token.withOptionalValueis the raw string, parsed and validated like a typed--watch=<value>. So it works underFlag.map,Flag.withDefault, choices and so on.--watch, -w [=choice]. The wizard writes the value inline. Shell completions stop expecting a separate value word after these flags; zsh also completes--watch=<TAB>.Branch: https://github.com/jayhemnani9910/effect/tree/feat/flag-optional-value
It touches
Param/Flag, one branch in the parser'sconsumeFlagValue, and help, wizard and completions. It comes with tests and a changeset.IMax153 commentedon Oct 13, 2026
@jayhemnani9910 feel free to open a PR, thanks!