pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.42k stars 370 forks source link

`--help` after the command treats `--help` as positional argument #982

Open scottopell opened 10 months ago

scottopell commented 10 months ago

I have a repro where --help is incorrectly treated as a positional arg instead of triggering the invoke command help printout. https://github.com/scottopell/invoke-help-bug

I've read through #205 and from what I understand this is not expected, --help and other core flags should be parsed out before task execution from what I understand.

Are there any suggested workarounds? Or is this unavoidable when the task takes positional arguments?

cupen commented 7 months ago

I can fix it. but I don't like invoke --help taskname, why not just invoke taskname --help. It's more *nix style, which is default case in most scenarios.

tonygoldman commented 6 months ago

Agreed! invoke taskname --help should be the standard.

bitprophet commented 1 month ago

This used to work (99% certainty) but has been broken for quite some time. It definitely should work! I have to take a look at the gnarly old guts of the parser to see why it's broken and how it can be fixed.

It will probably come down to a judgement call - if a token could be either a positional value or a flag, we will assume it's a flag, because that is obviously the more common/likely case.

(Suppose we could afterwards add an argument to @task for folks who very badly want to override that behavior to how it currently behaves, but, eh.)