datalad.cmdline.helpers

class datalad.cmdline.helpers.ArgumentParserDisableAbbrev(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)[source]

Bases: argparse.ArgumentParser

class datalad.cmdline.helpers.HelpAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: argparse.Action

class datalad.cmdline.helpers.LogLevelAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: argparse.Action

datalad.cmdline.helpers.add_entrypoints_to_interface_groups(interface_groups)[source]
datalad.cmdline.helpers.fail_with_short_help(parser=None, msg=None, known=None, provided=None, hint=None, exit_code=1, what='command', out=None)[source]

Generic helper to fail with short help possibly hinting on what was intended if known were provided

datalad.cmdline.helpers.get_commands_from_groups(groups)[source]

Get a dictionary of command: interface_spec

datalad.cmdline.helpers.get_description_with_cmd_summary(grp_short_descriptions, interface_groups, parser_description)[source]
datalad.cmdline.helpers.get_repo_instance(path='.', class_=None)[source]

Returns an instance of appropriate datalad repository for path. Check whether a certain path is inside a known type of repository and returns an instance representing it. May also check for a certain type instead of detecting the type of repository.

Parameters:
  • path (str) – path to check; default: current working directory
  • class (class) – if given, check whether path is inside a repository, that can be represented as an instance of the passed class.
Raises:

RuntimeError, in case cwd is not inside a known repository.

datalad.cmdline.helpers.parser_add_common_opt(parser, opt, names=None, **kwargs)[source]
datalad.cmdline.helpers.parser_add_common_options(parser, version=None)[source]
datalad.cmdline.helpers.parser_add_version_opt(parser, mod_name, include_name=False, delay=False)[source]

Setup –version option

Parameters:
  • parser
  • mod_name (str, optional) –
  • include_name (bool, optional) –
  • delay (bool, optional) – If set to True, no action is taken immediately, and rather we assign the function which would print the version. Necessary for early pre-parsing of the cmdline
datalad.cmdline.helpers.run_via_pbs(args, pbs)[source]
datalad.cmdline.helpers.strip_arg_from_argv(args, value, opt_names)[source]

Strip an originally listed option (with its value) from the list cmdline args