rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.12k stars 552 forks source link

Draft: Fix negated option value when followed by argument #772

Closed neomilium closed 2 years ago

neomilium commented 2 years ago

I'm facing a boolean option parsing error: when using negated option (e.g. --no-foo) followed by argument, the parsed value is not the expected one.

Context: In modulesync, we use thor. I expect to contribute a new command to be used like this:

msync execute --no-fail-fast -- /path/to/script --script-option

But the options hash returned by thor after parsing this command line is:

{
"fail_fast" => true
}

Which is not the expected value ;-)

Please note that if --no-fail-fast option is the last one, its OK:

$ msync execute --no-fail-fast 
{
"fail_fast" => false
}
$ msync execute /path/to/script --no-fail-fast 
{
"fail_fast" => false
}

First, I commited a small test, attempting to target the problem.

neomilium commented 2 years ago

This bug was a side-effect of system's thor load (through system's bundle command).

Solved uninstalling ruby-thor package (and ruby-bundler) and install them through gem.