Repository navigation
Conversation
`linode-cli help linodes` and `linode-cli linodes help` failed with "Unrecognized command help" and "Action not found for command linodes: help". Treat `help` given as the command or the action like the --help flag, so both show the same help as `linode-cli linodes --help`; `linode-cli help` shows the default help and `linode-cli help linodes create` the help for an action. Only the command and action positions are rewritten, since `help` elsewhere can be a value, such as a bucket name in `linode-cli obj mb help`. argv is changed in place, so plugins, which read it directly, see the --help flag too. Fixes linode#868
lyelgate
requested review from
jriddle-linode and
psnoch-akamai
and removed request for
a team
November 1, 2026 11:35
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
What does this PR do and why is this change necessary?
Fixes #868.
helpnow works like the--helpflag when given as the command or the action:linode-cli helpUnrecognized command help(exit 1)linode-cli --helplinode-cli help linodesUnrecognized command help(exit 1)linode-cli linodes --helplinode-cli linodes helpAction not found for command linodes: help(exit 2)linode-cli linodes --helplinode-cli help linodes createUnrecognized command help(exit 1)linode-cli linodes create --helplinode-cli obj helplinode-cli obj --helpThis is a new take on #878, which was closed with review feedback outstanding. The feedback is addressed:
sys.argvis changed in place, not reassigned.linodecli/__init__.pyholdsfrom sys import argvand builds plugin arguments from it, so reassigning would desync them.help_subcommand_to_flagdeletes thehelptoken and appends--helpon the same list, thenmain()re-parses with the same parser.linode-cli --json linodes help) still work, andhelpas a value is untouched:linode-cli obj mb helpstill creates a bucket namedhelp, andlinode-cli linodes view helpstill passeshelpas the ID.help <command>and<command> helpforms.✔️ How to Test
What are the steps to reproduce the issue or verify the changes?
With a baked spec, I compared the output of each of these and of
linode-cli helpwith its--helpequivalent. They are identical, with exit code 0.How do I run the relevant unit/integration tests?
The tests run each case through the real
register_argsparser and check the rewritten arguments: six rewritten forms (including a global option before the command, a plugin, and that the list is changed in place) and four that must be left alone.black,isort,autoflakeandpylintpass, and so doesmake test-unit(250 tests) with a baked spec.