def add_command_parsers(subparsers):
    # Note, there is no 'list' command here because the client
    # or REST can be used for list operations. Default templates
    # will display, and templates will show the 'is_default' field.

    def add_id(parser):
        parser.add_argument('--id', required=True,
                            help='The id of the default '
                                 'template to delete')

    def add_tenant_id(parser):
        parser.add_argument('-t', '--tenant_id', required=True,
                            help='Tenant ID for database operations.')

    def add_name_and_tenant_id(parser):
        parser.add_argument('--name', dest='template_name', required=True,
                            help='Name of the default template')
        add_tenant_id(parser)

    def add_plugin_name_and_version(parser, require_plugin_name=False):

        plugin_name_help = ('Only process templates containing '
                            'a "plugin_name" field matching '
                            'one of these values.')

        if not require_plugin_name:
            extra = (' The default list of plugin names '
                     'is taken from the "plugins" parameter in '
                     'the [DEFAULT] config section.')
            plugin_name_help += extra

        parser.add_argument('-p', '--plugin-name', nargs="*",
                            required=require_plugin_name,
                            help=plugin_name_help)

        parser.add_argument('-pv', '--plugin-version', nargs="*",
                            help='Only process templates containing a '
                                 '"hadoop_version" field matching one of '
                                 'these values. This option is '
                                 'only valid if --plugin-name is specified '
                                 'as well. A version specified '
                                 'here may optionally be prefixed with a '
                                 'plugin name and a dot, for example '
                                 '"vanilla.1.2.1". Dotted versions only '
                                 'apply to the plugin named in the '
                                 'prefix. Versions without a prefix apply to '
                                 'all plugins.')

    fname = pkg.resource_filename(version.version_info.package,
                                  "plugins/default_templates")
    # update command
    parser = subparsers.add_parser('update',
                                   help='Update the default template set')
    parser.add_argument('-d', '--directory',
                        default=fname,
                        help=fname % 'Template directory. Default is %s')
    parser.add_argument('-n', '--norecurse', action='store_true',
                        help='Do not descend into subdirectories')

    add_plugin_name_and_version(parser)
    add_tenant_id(parser)
    parser.set_defaults(func=api.do_update)

    # delete command
    parser = subparsers.add_parser('delete',
                                   help='Delete default templates '
                                        'by plugin and version')
    add_plugin_name_and_version(parser, require_plugin_name=True)
    add_tenant_id(parser)
    parser.set_defaults(func=api.do_delete)

    # node-group-template-delete command
    parser = subparsers.add_parser('node-group-template-delete',
                                   help='Delete a default '
                                        'node group template by name')
    add_name_and_tenant_id(parser)
    parser.set_defaults(func=api.do_node_group_template_delete)

    # cluster-template-delete command
    parser = subparsers.add_parser('cluster-template-delete',
                                   help='Delete a default '
                                        'cluster template by name')
    add_name_and_tenant_id(parser)
    parser.set_defaults(func=api.do_cluster_template_delete)

    # node-group-template-delete-id command
    parser = subparsers.add_parser('node-group-template-delete-id',
                                   help='Delete a default '
                                        'node group template by id')
    add_id(parser)
    parser.set_defaults(func=api.do_node_group_template_delete_by_id)

    # cluster-template-delete-id command
    parser = subparsers.add_parser('cluster-template-delete-id',
                                   help='Delete a default '
                                        'cluster template by id')
    add_id(parser)
    parser.set_defaults(func=api.do_cluster_template_delete_by_id)
dataset/ETHPy150Open openstack/sahara/sahara/db/templates/cli.py/add_command_parsers/swapped operands of `%`