Skip to content

[question] Subcommand completion support for proper parsers #154

@nicholasjng

Description

@nicholasjng

Hey, thanks for creating this!

I wanted to start using it in a CLI project of my own, but before adoption, I am facing a usability question, which I was not able to find an immediate answer to.

Does shtab support the "one ArgumentParser per command class" use case?

Briefly explained, in this model, each CLI command inherits from a Command base class, which defines a parser for that specific argument only. Resolving the subcommand can then happen in an argument parser for the bare command. An example of a project using this is pip, with the base command implemented here.

Whereas for dvc, each command gets a subparser added to the single main dvc command parser, and the completion is added to the base parser, if I understood correctly.

The completion I am looking for would then do, say for two available subcommands bb and bbcc,

prog b<TAB>
# bb bbcc

Is this possible to do in current shtab if both of my bb and bbcc subcommands have their own argument parsers, as well as the base prog parser?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions