Skip to content

Is there an intended way to pass modifed or added arguments from a parent parser to a one or more subparsers when using the with_annotated decorator? #1690

@neoniobium

Description

@neoniobium

Question / Feature Request

Is there an intended way to modify, add, or pass arguments from a parent parser to a subparser when using the with_annotated decorator?

With the with_argparse approach this is straightforward because you have access to the full namespace.

Example:

class App(Cmd):

    @with_annotated(subcommand_to=parent)
    def do_sub(...) -> None:
        ...  # use possibly modified parent_argument here

    @with_annotated(base_command=True)
    def do_parent(parent_argument: ...) -> None:
        ...  # possibly modify parent_argument here

I would like to use parent_argument (defined on the parent parser) in do_sub either as an argument hidden from the subparser or by accessing the full namespace of the parser.

Is ns_provider intended for this use case? If so I cannot see how.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions