You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@mitsuhiko proposed to use Click 5 and what I've been doing last year. I don't see any progress on #473 and thought that maybe is something wrong with implementation?
Really, I need ctx.args leftover arguments on TOP level to determine different options from subcomamnds. For example, if deep subcommand supports --json option and developer uses it, I should be "silent" and don't print any info to stdout (planned updates, maintaince operations etc) because it will break final JSON. That is only the one use case.
The questions:
Do you know other approach how to receive a subcommand path from TOP/ROOT context?
How to receive a final context of subcommand having TOP context?
Using sys.argv without parsing will not help me. I have mix of deep commands/sub-commands. for example, pio command1 arg_cmd_1 --option_cmd_1 subcommand arg_cmd_subcommand. How to receive in this case path like [command1, subcommand]?
I see a few other options that requires some refactoring to existing @platformio code and allow to switch to Click 6 and above:
Manually parse sys.argv - isn't good approach
Define custom Click-based Command class for @click.command(cls=MyCommand) where I'll know which command was called.
Activity
nckswt commentedon Mar 7, 2019
kdeldycke commentedon Aug 26, 2025
Related to this discussion, I developed a set of utilities which are introspecting Click CLI and recreate the structure of the commands/groups/parameters tree.
I am currently relying on that code to automatically mirror a CLI into its configuration file and have an automatic
--show-paramsto introspect a CLI structure.This is part of my Click Extra project to improve on Click.