command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

Option with default value does not have Action added to PreActions

Open barrygiles opened this issue 5 months ago • 1 comments

Say there is an QuietOption which is a boolean and has some action associated with it.

If --quiet is specified on the command line, the associated action gets added to the PreAction list and is executed before the main command action.

If --quiet is not specified on the command line, but instead it is given a default value - say driven from configuration - then the associated action is not added to the PreAction list and is not executed.

As far as the parse result is concerned, both of these look the same and so should function the same, i.e. the --quiet option has been supplied somehow and action should happen accordingly.

barrygiles avatar Jul 08 '25 16:07 barrygiles

Edit: Nevermind. I messed up my local test run.

~This sounds like a pretty simple case but I realized after "fixing" it that the test passes even without the change in the library code. @barrygiles Would you mind taking a look at the PR and verifying that the test I added describes the issue you're seeing? I'm wondering whether the behavior was incidentally fixed at some point or the test is wrong.~

jonsequitur avatar Oct 16 '25 23:10 jonsequitur