xonsh.main¶
The main xonsh script.
- class xonsh.main.XonshMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- interactive = 3¶
- script_from_file = 1¶
- script_from_stdin = 2¶
- single_command = 0¶
- xonsh.main.main_context(argv=None)[source]¶
Generator that runs pre- and post-main() functions. This has two iterations. The first yields the shell. The second returns None but cleans up the shell.
- xonsh.main.path_argument(s)[source]¶
Return a path only if the path is actually legal (file or directory)
This is very similar to argparse.FileType, except that it doesn’t return an open file handle, but rather simply validates the path.
- xonsh.main.postmain(args=None)[source]¶
Teardown for main xonsh entry point, accepts parsed arguments.
- xonsh.main.setup(ctx=None, shell_type='none', env=(('RAISE_SUBPROC_ERROR', True),), aliases=(), xontribs=(), threadable_predictors=())[source]¶
Starts up a new xonsh shell. Calling this in function in another packages
__init__.py
will allow xonsh to be fully used in the package in headless or headed mode. This function is primarily indended to make starting up xonsh for 3rd party packages easier.Here is example of using this at the top of an
__init__.py
:from xonsh.main import setup setup() del setup
- Parameters:
- ctxdict-like or None, optional
The xonsh context to start with. If None, an empty dictionary is provided.
- shell_typestr, optional
The type of shell to start. By default this is ‘none’, indicating we should start in headless mode.
- envdict-like, optional
Environment to update the current environment with after the shell has been initialized.
- aliasesdict-like, optional
Aliases to add after the shell has been initialized.
- xontribsiterable of str, optional
Xontrib names to load.
- threadable_predictorsdict-like, optional
Threadable predictors to start up with. These overide the defaults.