Skip to content

Comments

Fix --help consumed as positional arg value#1059

Open
Fridayai700 wants to merge 1 commit intopyinvoke:mainfrom
Fridayai700:fix-help-positional-982
Open

Fix --help consumed as positional arg value#1059
Fridayai700 wants to merge 1 commit intopyinvoke:mainfrom
Fridayai700:fix-help-positional-982

Conversation

@Fridayai700
Copy link

Summary

  • Fixes --help after the command treats --help as positional argument #982
  • When a task has required positional arguments, --help after the task name was consumed as the positional arg's value instead of being recognized as the help flag
  • Root cause: in ParseMachine.handle(), the positional-args elif branch came before the initial-context flags check, so --help was eaten as a positional value
  • Fix: reorder the elif chain so initial-context flags are checked before positional args, and skip positional arg validation when --help was requested

Test plan

  • Added test: task with required positional arg + --help → help flag is set, not consumed as positional value
  • All 61 parser tests pass
  • Full test suite passes (1 pre-existing unrelated failure in tests/runners.py)

When a task has required positional arguments, `--help` was being eaten
as a positional arg value instead of being recognized as the help flag.
This happened because the positional-args elif branch came before the
initial-context flags check.

Fix by reordering the elif chain so initial-context flags (like --help)
are checked before positional args. Also skip positional arg validation
in complete_context() when --help was requested, since the user is
asking for help, not trying to invoke the task.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--help after the command treats --help as positional argument

1 participant