invoke API reference
98 public APIs from invoke (pyinvoke/invoke) — 18 classes, 14 functions, 66 methods. Signatures extracted by static analysis of the actual source.
Repository: pyinvoke/invoke
| Kind | Count |
|---|---|
| Classes | 18 |
| Functions | 14 |
| Methods | 66 |
API list
func
integration._explicit.foo(c:Context) -> NoneFrobazz
func
integration._util.only_utf8(f:Callable) -> CallableDecorator causing tests to skip if local shell pipes aren't UTF-8.
class
integration.runners.Runner_.IO_hangsIO hangs
class
invoke.collection.CollectionA collection of executable tasks.
method
invoke.collection.Collection.add_task(task:'Task', name:Optional[str]=None, aliases:Optional[Tuple[str, ...]]=None, default:Optional[bool]=None) -> NoneAdd `.Task` ``task`` to this collection.
method
invoke.collection.Collection.configuration(taskpath:Optional[str]=None) -> Dict[str, Any]Obtain merged configuration values from collection & children.
method
invoke.collection.Collection.configure(options:Dict[str, Any]) -> None(Recursively) merge ``options`` into the current `.configuration`.
method
invoke.collection.Collection.subcollection_from_path(path:str) -> 'Collection'Given a ``path`` to a subcollection, return that subcollection.
method
invoke.collection.Collection.task_with_config(name:Optional[str]) -> Tuple[str, Dict[str, Any]]Return task named ``name`` plus its configuration dict.
method
invoke.collection.Collection.transform(name:str) -> strTransform ``name`` with the configured auto-dashes behavior.
class
invoke.config.ConfigInvoke's primary configuration handling class.
method
invoke.config.Config.clone(into:Optional[Type['Config']]=None) -> 'Config'Return a copy of this configuration object.
method
invoke.config.Config.global_defaults() -> Dict[str, Any]Return the core default settings for Invoke.
method
invoke.config.Config.load_collection(data:Dict[str, Any], merge:bool=True) -> NoneUpdate collection-driven config data.
method
invoke.config.Config.load_defaults(data:Dict[str, Any], merge:bool=True) -> NoneSet or replace the 'defaults' configuration level, from ``data``.
method
invoke.config.Config.load_project(merge:bool=True) -> NoneLoad a project-level config file, if possible.
method
invoke.config.Config.load_runtime(merge:bool=True) -> NoneLoad a runtime-level config file, if one was specified.
method
invoke.config.Config.load_shell_env() -> NoneLoad values from the shell environment.
method
invoke.config.Config.load_system(merge:bool=True) -> NoneLoad a system-level config file, if possible.
method
invoke.config.Config.load_user(merge:bool=True) -> NoneLoad a user-level config file, if possible.
method
invoke.config.Config.merge() -> NoneMerge all config sources, in order.
method
invoke.config.Config.set_runtime_path(path:Optional[PathLike]) -> NoneSet the runtime config file path.
class
invoke.config.DataProxyHelper class implementing nested dict+attr access for `.Config`.
func
invoke.config.obliterate(base:Dict[str, Any], deletions:Dict[str, Any]) -> NoneRemove all (nested) keys mentioned in ``deletions``, from ``base``.
class
invoke.context.ContextContext-aware API wrapper & state-passing object.
method
invoke.context.Context.run(command:str, **kwargs:Any) -> ResultExecute a local shell command, honoring config options.
method
invoke.context.Context.sudo(command:str, **kwargs:Any) -> ResultExecute a shell command via ``sudo`` with password auto-response.
class
invoke.context.MockContextA `.Context` whose methods' return values can be predetermined.
method
invoke.context.MockContext.set_result_for(attname:str, command:str, result:Result) -> NoneModify the stored mock results for given ``attname`` (e.g.
method
invoke.env.Environment.load() -> Dict[str, Any]Return a nested dict containing values from `os.environ`.
class
invoke.exceptions.AuthFailureAn authentication failure, e.g.
class
invoke.exceptions.ExitSimple custom stand-in for SystemExit.
class
invoke.exceptions.FailureException subclass representing failure of a command execution.
class
invoke.exceptions.ThreadExceptionOne or more exceptions were raised within background threads.
class
invoke.executor.ExecutorAn execution strategy for Task objects.
method
invoke.executor.Executor.dedupe(calls:List['Call']) -> List['Call']Deduplicate a list of `tasks <.Call>`.
method
invoke.executor.Executor.execute(*tasks:Union[str, Tuple[str, Dict[str, Any]], ParserContext]) -> Dict['Task', 'Result']Execute one or more ``tasks`` in sequence.
method
invoke.executor.Executor.expand_calls(calls:List['Call']) -> List['Call']Expand a list of `.Call` objects into a near-final list of same.
class
invoke.loader.FilesystemLoaderLoads Python files from the filesystem (e.g.
method
invoke.loader.Loader.find(name:str) -> Optional[ModuleSpec]Implementation-specific finder method seeking collection ``name``.
method
invoke.loader.Loader.load(name:Optional[str]=None) -> Tuple[ModuleType, str]Load and return collection module identified by ``name``.
class
invoke.parser.argument.ArgumentA command-line argument/flag.
method
invoke.parser.argument.Argument.name() -> Optional[str]The canonical attribute-friendly name for this argument.
method
invoke.parser.argument.Argument.set_value(value:Any, cast:bool=True) -> NoneActual explicit value-setting API call.
class
invoke.parser.context.ParserContextParsing context with knowledge of flags & their format.
method
invoke.parser.context.ParserContext.help_for(flag:str) -> Tuple[str, str]Return 2-tuple of ``(flag-spec, help-string)`` for given ``flag``.
func
invoke.parser.context.flag_key(arg:Argument) -> List[Union[int, str]]Obtain useful key list-of-ints for sorting CLI flags.
class
invoke.parser.parser.ParseResultList-like object with some extra parse-related attributes.
method
invoke.parser.parser.Parser.parse_argv(argv:List[str]) -> ParseResultParse an argv-style token list ``argv``.
method
invoke.program.Program.args() -> 'Lexicon'Obtain core program args from ``self.core`` parse result.
method
invoke.program.Program.called_as() -> strReturns the program name we were actually called as.
method
invoke.program.Program.core_args() -> List['Argument']Return default core `.Argument` objects, as a list.
method
invoke.program.Program.initial_context() -> ParserContextThe initial parser context, aka core program flags.
method
invoke.program.Program.name() -> strDerive program's human-readable name based on `.binary`.
method
invoke.program.Program.normalize_argv(argv:Optional[List[str]]) -> NoneMassages ``argv`` into a useful list of strings.
method
invoke.program.Program.parse_collection() -> NoneLoad a tasks collection & project-level config.
method
invoke.program.Program.print_columns(tuples:Sequence[Tuple[str, Optional[str]]]) -> NonePrint tabbed columns from (name, help) ``tuples``.
method
invoke.program.Program.print_task_help(name:str) -> NonePrint help for a specific task, e.g.
method
invoke.program.Program.run(argv:Optional[List[str]]=None, exit:bool=True) -> NoneExecute main CLI logic, based on ``argv``.
method
invoke.program.Program.update_config(merge:bool=True) -> NoneUpdate the previously instantiated `.Config` with parsed data.
func
invoke.run(command:str, **kwargs:Any) -> ResultRun ``command`` in a subprocess and return a `.Result` object.
class
invoke.runners.LocalExecute a command on the local system in a subprocess.
class
invoke.runners.ResultA container for information about the result of a command execution.
method
invoke.runners.Result.failed() -> boolThe inverse of ``ok``.
method
invoke.runners.Result.ok() -> boolA boolean equivalent to ``exited == 0``.
method
invoke.runners.Result.return_code() -> intAn alias for ``.exited``.
method
invoke.runners.Result.tail(stream:str, count:int=10) -> strReturn the last ``count`` lines of ``stream``, plus leading whitespace.
class
invoke.runners.RunnerPartially-abstract core command-running API.
method
invoke.runners.Runner.close_proc_stdin() -> NoneClose running process' stdin.
method
invoke.runners.Runner.decode(data:bytes) -> strDecode some ``data`` bytes, returning Unicode.
method
invoke.runners.Runner.get_pid() -> Optional[int]When possible, obtain the subprocess PID.
method
invoke.runners.Runner.handle_stderr(buffer_:List[str], hide:bool, output:IO) -> NoneRead process' stderr, storing into a buffer & printing/parsing.
method
invoke.runners.Runner.handle_stdin(input_:IO, output:IO, echo:bool=False) -> NoneRead local stdin, copying into process' stdin as necessary.
method
invoke.runners.Runner.handle_stdout(buffer_:List[str], hide:bool, output:IO) -> NoneRead process' stdout, storing into a buffer & printing/parsing.
method
invoke.runners.Runner.kill() -> NoneForcibly terminate the subprocess.
method
invoke.runners.Runner.process_is_finished() -> boolDetermine whether our subprocess has terminated.
method
invoke.runners.Runner.read_our_stdin(input_:IO) -> Optional[str]Read & decode bytes from a local stdin stream.
method
invoke.runners.Runner.read_proc_stderr(num_bytes:int) -> Optional[bytes]Read ``num_bytes`` from the running process' stderr stream.
method
invoke.runners.Runner.read_proc_stdout(num_bytes:int) -> Optional[bytes]Read ``num_bytes`` from the running process' stdout stream.
method
invoke.runners.Runner.respond(buffer_:List[str]) -> NoneWrite to the program's stdin in response to patterns in ``buffer_``.
method
invoke.runners.Runner.run(command:str, **kwargs:Any) -> 'Result'Execute ``command``, returning an instance of `Result` once complete.
method
invoke.runners.Runner.send_interrupt(interrupt:'KeyboardInterrupt') -> NoneSubmit an interrupt signal to the running subprocess.
method
invoke.runners.Runner.should_use_pty(pty:bool, fallback:bool) -> boolShould execution attempt to use a pseudo-terminal?
method
invoke.runners.Runner.start(command:str, shell:str, env:Dict[str, Any]) -> NoneInitiate execution of ``command`` (via ``shell``, with ``env``).
method
invoke.runners.Runner.start_timer(timeout:int) -> NoneStart a timer to `kill` our subprocess after ``timeout`` seconds.
method
invoke.runners.Runner.stop() -> NonePerform final cleanup, if necessary.
method
invoke.runners.Runner.wait() -> NoneBlock until the running command appears to have exited.
method
invoke.runners.Runner.write_our_output(stream:IO, string:str) -> NoneWrite ``string`` to ``stream``.
method
invoke.runners.Runner.write_proc_stdin(data:str) -> NoneWrite encoded ``data`` to the running process' stdin.
func
invoke.runners.default_encoding() -> strObtain apparent interpreter-local default text encoding.
func
invoke.sudo(command:str, **kwargs:Any) -> ResultRun ``command`` in a ``sudo`` subprocess and return a `.Result` object.
func
invoke.terminals.bytes_to_read(input_:IO) -> intQuery stream ``input_`` to see how many bytes may be readable.
func
invoke.terminals.character_buffered(stream:IO) -> Generator[None, None, None]Force local terminal ``stream`` be character, not line, buffered.
func
invoke.terminals.pty_size() -> Tuple[int, int]Determine current local pseudoterminal dimensions.
func
invoke.terminals.ready_for_reading(input_:IO) -> boolTest ``input_`` to determine whether a read action will succeed.
func
invoke.util.has_fileno(stream:IO) -> boolCleanly determine whether ``stream`` has a useful ``.fileno()``.
func
invoke.util.isatty(stream:IO) -> Union[bool, Any]Cleanly determine whether ``stream`` is a TTY.
func
invoke.util.task_name_sort_key(name:str) -> Tuple[List[str], str]Return key tuple for use sorting dotted task names, via e.g.
About this data
These signatures were extracted from the public source of pyinvoke/invoke
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.