rich-click
rich-click copied to clipboard
`--tree` integration
Add support for a tree-representation of nested CLI argument grouping, such as done in the TreeClick click plugin by @wr1 (this issue is created after he reached out to @ewels).
This view helps to maintain context in complex CLI tools by showing where a given command is located when printing output from --help:
Suggestion is to add this behaviour to rich-click in an opt-in manner.
Core
https://github.com/wr1/treeclick/tree/master
Implementations
- [ ]
@click.tree_option() - [ ]
rich-click --tree [cmd]which generates a tree of any Click CLI.- [ ] Verify works on non-rich click CLI
- [ ] Verify works on Typer CLI
- [ ]
@click.group(context_settings={"tree_option_names": ["--tree"]})<- adds tree option if set
Other
- [ ] Documentation
- [ ] Its own page
- [ ] Update to rich-click CLI page
- [ ] Unit-tests
Considerations
- Config options. Some styling options may make sense to come from existing config options, but other config may need to have its own stuff under
tree_*.- All core tree behaviors should be able to be set via
tree_option(), like depth, showing usage text, etc. Not sure how deep we'd go in exposing literally everything though like colors, style etc. - tree should play nicely with existing themes implementation, so e.g.
--treewith{"theme": "quartz"}should look like the quartz theme.
- All core tree behaviors should be able to be set via
- What is default behavior? By default, should "--tree" look like help text? I.e. should it, by default, show a strict superset of all the same contents that --help would? (So that includes text, options, args) Or should it be a more compressed view of individual commands' functionality focusing on uncovering the breadth of a CLI, so that it works alongside help text to surface different information than it?
- Surely even if the default is that it just shows the top-level options+args, but only shows subcommands recursively without their options+args, the depth at which it stops showing args/options or even subcommands, and whether it shows usage text at all, should all be configurable. 'm just speaking strictly about what is the default behavior of the tree option.
- A potential issue with showing literally everything as a default behavior is that seeing a recursive structure for a CLI is useful for complex CLIs, but in turn complex CLIs are, well, complex, and showing literally everything can print like 3,000 lines in your terminal, which makes the text too noisy and thus less useful.