conda_argparse#

Conda command line interface parsers.

Classes#

ArgumentParser

Object for parsing command line strings into Python objects.

_GreedySubParsersAction

A custom subparser action to conditionally act as a greedy consumer.

NullCountAction

Information about how to convert command line strings to Python objects.

ExtendConstAction

Information about how to convert command line strings to Python objects.

Functions#

generate_pre_parser(→ ArgumentParser)

generate_parser(→ ArgumentParser)

do_call(args, parser)

Serves as the primary entry point for commands referred to in this file and for

find_builtin_commands(parser)

_exec(executable_args, env_vars)

_exec_win(executable_args, env_vars)

_exec_unix(executable_args, env_vars)

configure_parser_plugins(→ None)

For each of the provided plugin-based subcommands, we'll create

configure_parser_clean(sub_parsers)

configure_parser_info(sub_parsers)

configure_parser_config(sub_parsers)

configure_parser_create(sub_parsers)

configure_parser_init(sub_parsers)

configure_parser_install(sub_parsers)

configure_parser_list(sub_parsers)

configure_parser_compare(sub_parsers)

configure_parser_package(sub_parsers)

configure_parser_remove(sub_parsers, aliases)

configure_parser_run(sub_parsers)

configure_parser_search(sub_parsers)

configure_parser_update(sub_parsers, aliases)

configure_parser_notices(sub_parsers[, name])

configure_parser_rename(→ None)

add_parser_create_install_update(p[, prefix_required])

add_parser_pscheck(p)

add_parser_show_channel_urls(p)

add_parser_help(p)

So we can use consistent capitalization and periods in the help. You must

add_parser_prefix(p[, prefix_required])

add_parser_json(p)

add_output_and_prompt_options(p)

add_parser_channels(p)

add_parser_solver_mode(p)

add_parser_update_modifiers(solver_mode_options)

add_parser_prune(p)

add_parser_solver(p)

Add a command-line flag for alternative solver backends.

add_parser_networking(p)

add_parser_package_install_options(p)

add_parser_known(p)

add_parser_default_packages(p)

add_parser_platform(parser)

add_parser_verbose(parser)

Attributes#

escaped_user_rc_path

escaped_sys_rc_path

BUILTIN_COMMANDS

NOTICES_HELP

NOTICES_DESCRIPTION

escaped_user_rc_path#
escaped_sys_rc_path#
BUILTIN_COMMANDS#
generate_pre_parser(**kwargs) ArgumentParser#
generate_parser(**kwargs) ArgumentParser#
do_call(args: argparse.Namespace, parser: ArgumentParser)#

Serves as the primary entry point for commands referred to in this file and for all registered plugin subcommands.

find_builtin_commands(parser)#
class ArgumentParser(*args, add_help=True, **kwargs)#

Bases: argparse.ArgumentParser

Object for parsing command line strings into Python objects.

Keyword Arguments:
  • (default (- usage -- A usage message) -- os.path.basename(sys.argv[0]))

  • (default -- auto-generated from arguments)

  • does (- description -- A description of what the program) --

  • descriptions (- epilog -- Text following the argument) --

  • one (- parents -- Parsers whose arguments should be copied into this) --

  • messages (- formatter_class -- HelpFormatter class for printing help) --

  • arguments (- argument_default -- The default value for all) --

  • containing (- fromfile_prefix_chars -- Characters that prefix files) -- additional arguments

  • arguments --

  • conflicts (- conflict_handler -- String indicating how to handle) --

  • option (- add_help -- Add a -h/-help) --

  • unambiguously (- allow_abbrev -- Allow long options to be abbreviated) --

  • with (- exit_on_error -- Determines whether or not ArgumentParser exits) -- error info when an error occurs

_check_value(action, value)#
parse_args(*args, override_args=None, **kwargs)#
class _GreedySubParsersAction(option_strings, prog, parser_class, dest=SUPPRESS, required=False, help=None, metavar=None)#

Bases: argparse._SubParsersAction

A custom subparser action to conditionally act as a greedy consumer.

This is a workaround since argparse.REMAINDER does not work as expected, see python/cpython#61252.

__call__(parser, namespace, values, option_string=None)#
_get_subactions()#

Sort actions for subcommands to appear alphabetically in help blurb.

_exec(executable_args, env_vars)#
_exec_win(executable_args, env_vars)#
_exec_unix(executable_args, env_vars)#
class NullCountAction(option_strings, dest, default=None, required=False, help=None)#

Bases: argparse._CountAction

Information about how to convert command line strings to Python objects.

Action objects are used by an ArgumentParser to represent the information needed to parse a single argument from one or more strings from the command line. The keyword arguments to the Action constructor are also all attributes of Action instances.

Keyword Arguments:
  • which (- option_strings -- A list of command-line option strings) -- should be associated with this action.

  • object (- dest -- The name of the attribute to hold the created) --

  • be (- nargs -- The number of command-line arguments that should) --

    consumed. By default, one argument will be consumed and a single value will be produced. Other values include:

    • N (an integer) consumes N arguments (and produces a list)

    • '?' consumes zero or one arguments

    • '*' consumes zero or more arguments (and produces a list)

    • '+' consumes one or more arguments (and produces a list)

    Note that the difference between the default and nargs=1 is that with the default, a single value will be produced, while with nargs=1, a list containing a single value will be produced.

  • the (- metavar -- The name to be used for the option's argument with) -- option uses an action that takes no values.

  • specified. (- default -- The value to be produced if the option is not) --

  • and (- type -- A callable that accepts a single string argument,) -- returns the converted value. The standard Python types str, int, float, and complex are useful examples of such callables. If None, str is used.

  • None, (- choices -- A container of values that should be allowed. If not) -- after a command-line argument has been converted to the appropriate type, an exception will be raised if it is not a member of this collection.

  • the -- command line. This is only meaningful for optional command-line arguments.

  • argument. (- help -- The help string describing the) --

  • the -- help string. If None, the 'dest' value will be used as the name.

static _ensure_value(namespace, name, value)#
__call__(parser, namespace, values, option_string=None)#
class ExtendConstAction(option_strings, dest, const, default=None, type=None, choices=None, required=False, help=None, metavar=None)#

Bases: argparse.Action

Information about how to convert command line strings to Python objects.

Action objects are used by an ArgumentParser to represent the information needed to parse a single argument from one or more strings from the command line. The keyword arguments to the Action constructor are also all attributes of Action instances.

Keyword Arguments:
  • which (- option_strings -- A list of command-line option strings) -- should be associated with this action.

  • object (- dest -- The name of the attribute to hold the created) --

  • be (- nargs -- The number of command-line arguments that should) --

    consumed. By default, one argument will be consumed and a single value will be produced. Other values include:

    • N (an integer) consumes N arguments (and produces a list)

    • '?' consumes zero or one arguments

    • '*' consumes zero or more arguments (and produces a list)

    • '+' consumes one or more arguments (and produces a list)

    Note that the difference between the default and nargs=1 is that with the default, a single value will be produced, while with nargs=1, a list containing a single value will be produced.

  • the (- metavar -- The name to be used for the option's argument with) -- option uses an action that takes no values.

  • specified. (- default -- The value to be produced if the option is not) --

  • and (- type -- A callable that accepts a single string argument,) -- returns the converted value. The standard Python types str, int, float, and complex are useful examples of such callables. If None, str is used.

  • None, (- choices -- A container of values that should be allowed. If not) -- after a command-line argument has been converted to the appropriate type, an exception will be raised if it is not a member of this collection.

  • the -- command line. This is only meaningful for optional command-line arguments.

  • argument. (- help -- The help string describing the) --

  • the -- help string. If None, the 'dest' value will be used as the name.

__call__(parser, namespace, values, option_string=None)#
configure_parser_plugins(sub_parsers) None#

For each of the provided plugin-based subcommands, we'll create a new subparser for an improved help printout and calling the configure_parser() with the newly created subcommand specific argument parser.

configure_parser_clean(sub_parsers)#
configure_parser_info(sub_parsers)#
configure_parser_config(sub_parsers)#
configure_parser_create(sub_parsers)#
configure_parser_init(sub_parsers)#
configure_parser_install(sub_parsers)#
configure_parser_list(sub_parsers)#
configure_parser_compare(sub_parsers)#
configure_parser_package(sub_parsers)#
configure_parser_remove(sub_parsers, aliases)#
configure_parser_run(sub_parsers)#
configure_parser_update(sub_parsers, aliases)#
NOTICES_HELP = 'Retrieve latest channel notifications.'#
NOTICES_DESCRIPTION#
configure_parser_notices(sub_parsers, name='notices')#
configure_parser_rename(sub_parsers) None#
add_parser_create_install_update(p, prefix_required=False)#
add_parser_pscheck(p)#
add_parser_show_channel_urls(p)#
add_parser_help(p)#

So we can use consistent capitalization and periods in the help. You must use the add_help=False argument to ArgumentParser or add_parser to use this. Add this first to be consistent with the default argparse output.

add_parser_prefix(p, prefix_required=False)#
add_parser_json(p)#
add_output_and_prompt_options(p)#
add_parser_channels(p)#
add_parser_solver_mode(p)#
add_parser_update_modifiers(solver_mode_options)#
add_parser_prune(p)#
add_parser_solver(p)#

Add a command-line flag for alternative solver backends.

See context.solver for more info.

add_parser_networking(p)#
add_parser_package_install_options(p)#
add_parser_known(p)#
add_parser_default_packages(p)#
add_parser_platform(parser)#
add_parser_verbose(parser)#