diff --git a/augur/argparse_.py b/augur/argparse_.py index d979b1acf..ac1861ccb 100644 --- a/augur/argparse_.py +++ b/augur/argparse_.py @@ -33,7 +33,7 @@ def run(args): parser.set_defaults(__command__ = default_command) -def register_commands(parser: argparse.ArgumentParser, commands): +def register_commands(parser: argparse.ArgumentParser, commands, command_attribute='__command__'): """ Add subparsers for each command module. @@ -56,6 +56,10 @@ def register_commands(parser: argparse.ArgumentParser, commands): # Allow each command to register its own subparser subparser = command.register_parser(subparsers) + # Add default attribute for command module + if command_attribute: + subparser.set_defaults(**{command_attribute: command}) + # Ensure all subparsers format like the top-level parser subparser.formatter_class = parser.formatter_class diff --git a/augur/curate/__init__.py b/augur/curate/__init__.py index 2b21ead8f..6b92b58f2 100644 --- a/augur/curate/__init__.py +++ b/augur/curate/__init__.py @@ -4,6 +4,7 @@ from . import format_dates, normalize_strings, passthru, titlecase, apply_geolocation_rules, apply_record_annotations, abbreviate_authors, parse_genbank_location, transform_strain_name, rename +SUBCOMMAND_ATTRIBUTE = '_curate_subcommand' SUBCOMMANDS = [ passthru, normalize_strings,