洪 民憙 (Hong Minhee) :nonbinary:'s avatar
洪 民憙 (Hong Minhee) :nonbinary:

@hongminhee@hollo.social · Reply to marius's post

@mariusor That's a good point for the Git example! However, from Optique's perspective as a general-purpose CLI parser, I don't think we can always assume that.

Some cases where a default value isn't straightforward:

  • The dependency option might be required with no default (e.g., --database <name> for table completions)
  • The default might need async computation (e.g., auto-detecting a Git root by traversing up directories)
  • Computing the default might be expensive, so we'd want to defer it until we know the option wasn't provided

That's why the current design has an explicit defaultValue function as the second argument to derive()—it gives users control over what happens when the dependency option is absent.

marius's avatar
marius

@mariusor@metalhead.club · Reply to 洪 民憙 (Hong Minhee) :nonbinary:'s post

> Some cases where a default value isn't straightforward

@hongminhee yes, I imagine most cases are like that, and this tells me that an API where the *command line parser* needs to introspect the application logic to this degree, is not that good of an API.