Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions on adding subcommands #1719

Open
victorlin opened this issue Jan 13, 2025 · 0 comments
Open

Add instructions on adding subcommands #1719

victorlin opened this issue Jan 13, 2025 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@victorlin
Copy link
Member

It would be good to document the required functions and general patterns that subcommand files are expected to follow.

This is from a proposal in 48b0891. I omitted the "Docstring" section since that was based on other unmerged changes in the PR, but some parts (e.g. "each command must start with a module docstring") may still be relevant.

Writing a command

Functions

Each command must include a function register_parser(parent_subparsers, **kwargs). See the docstring of augur.argparse_.add_command_subparsers for more information.

If a command has sub-commands, those should be added with augur.argparse_.add_command_subparsers.

Most commands should define a run(args) function which serves as the indirect entrypoint from the CLI, where args is the value given back by argparse.ArgumentParser.parse_args(). If this function is not defined, the help output will be shown.

@victorlin victorlin added the documentation Improvements or additions to documentation label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant