Skip to content

Please open github "discussion" feature #1081

@jedie

Description

@jedie

I have a Questions: How can one commandset call a command from a other commandset ?

The github discussions may be a better place for this, isn't it?

EDIT: About my Question: I found a way, e.g.:

class FooBarCommandSet(CommandSet):
    def do_foo(self, statement: cmd2.Statement = None):
        # ... do something ...

        # Call a other command from a other CommandSet:
        self._cmd.do_foobar(statement=statement)

May fail if the first command get's statement=None but the second needs a Statement instance, isn't it?

EDIT2: This seems to be a better idea:

class FooBarCommandSet(CommandSet):
    def do_foo(self, statement: cmd2.Statement = None):
        # ... do something ...

        # Call a other command from a other CommandSet:
        return self._cmd.onecmd_plus_hooks('foobar')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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