flexget.options module#
- class flexget.options.ArgumentParser(**kwargs)[source]#
Bases:
ArgumentParserMimics the default
argparse.ArgumentParserclass.There are a few distinctions, mostly to ease subparser usage:
If
add_subparsersis called with thenested_namespaceskwarg, all subcommand options will be stored in a nested namespace based on the command name for the subparserAdds the
add_subparsermethod. Afteradd_subparsershas been called, theadd_subparsermethod can be used instead of theadd_parsermethod of the object returned by theadd_subparserscall.add_subparsertakes takes theparent_defaultsargument, which will set/change the defaults for the parent parser when that subparser is selected.The
get_subparsermethod will get theArgumentParserinstance for an existing subparser on this parserFor any arguments defined both in this parser and one of its subparsers, the selected subparser default will override the main one.
Adds the
set_post_defaultsmethod. This works like the normal argparseset_defaultsmethod, but all actions and subparsers will be run before any of these defaults are set.Command shortening: If the command for a subparser is abbreviated unambiguously, it will still be accepted.
The add_argument
nargskeyword argument supports a range of arguments, e.g.2-4If the
raise_errorskeyword argument toparse_argsis True, aParserErrorwill be raised instead ofsys.exitIf the
fileargument is given toparse_args, output will be printed there instead ofsys.stdoutorstderr
- _print_message(message, file=None)[source]#
If a file argument was passed to parse_args make sure output goes there.
- add_argument(dest, ..., name=value, ...)[source]#
- add_argument(option_string, option_string, ..., name=value, ...)
- add_subparser(name, **kwargs)[source]#
Add a parser for a new subcommand and return it.
- Parameters:
name (str) – Name of the subcommand
parent_defaults – Default argument values which should be supplied to the parent parser if this subparser is selected.
- add_subparsers(**kwargs)[source]#
Add a parser for a new subcommand and return it.
- Parameters:
nested_namespaces – If True, options from subparsers will appear in nested namespace under the subparser name.
- error(message: string)[source]#
Prints a usage message incorporating the message to stderr and exits.
If you override this in a subclass, it should not return – it should either exit or raise an exception.
- Parameters:
msg (str)
- set_post_defaults(**kwargs)[source]#
Like set_defaults method, but these defaults will be defined after parsing instead of before.
- do_help = True#
- class flexget.options.CoreArgumentParser(**kwargs)[source]#
Bases:
ArgumentParserThe core argument parser, contains the manager arguments, command parsers, and plugin arguments.
Warning: Only gets plugin arguments if instantiated after plugins have been loaded.
- class flexget.options.CronAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)[source]#
Bases:
Action
- class flexget.options.DebugAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)[source]#
Bases:
Action
- class flexget.options.DebugTraceAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)[source]#
Bases:
Action
- class flexget.options.HelpAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)[source]#
Bases:
ActionOverride the default help command so that we can conditionally disable it to prevent program exit.
- class flexget.options.InjectAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)[source]#
Bases:
Action
- class flexget.options.ParseExtrasAction(option_strings, parser, help=None, metavar=None, dest=None, required=False)[source]#
Bases:
ActionExtra arguments are taken, and then parsed with a different parser.
- class flexget.options.VersionAction(option_strings, version=None, dest='==SUPPRESS==', default='==SUPPRESS==', help=None, deprecated=False)[source]#
Bases:
_VersionActionAction to print the current version. Also checks latest release revision.
- flexget.options.register_command(command, callback, **kwargs)[source]#
Register a callback function to be executed when flexget is launched with the given command.
- Parameters:
command (str) – The command being defined.
callback (Callable[[flexget.manager.Manager, Namespace], Any]) – Callback function executed when this command is invoked from the CLI. Should take manager instance and parsed argparse namespace as parameters.
kwargs – Other keyword arguments will be passed to the
arparse.ArgumentParserconstructor
- Returns:
An
argparse.ArgumentParserinstance ready to be configured with the options for this command.- Return type: