def premain(argv=None): """Setup for main xonsh entry point. Returns parsed arguments.""" if argv is None: argv = sys.argv[1:] setup_timings() setproctitle = get_setproctitle() if setproctitle is not None: setproctitle(" ".join(["xonsh"] + argv)) builtins.__xonsh__ = XonshSession() args = parser.parse_args(argv) if args.help: parser.print_help() parser.exit() if args.version: version = "/".join(("xonsh", __version__)) print(version) parser.exit() shell_kwargs = { "shell_type": args.shell_type, "completer": False, "login": False, "scriptcache": args.scriptcache, "cacheall": args.cacheall, "ctx": builtins.__xonsh__.ctx, } if args.login: shell_kwargs["login"] = True if args.norc: shell_kwargs["rc"] = () elif args.rc: shell_kwargs["rc"] = args.rc setattr(sys, "displayhook", _pprint_displayhook) if args.command is not None: args.mode = XonshMode.single_command shell_kwargs["shell_type"] = "none" elif args.file is not None: args.mode = XonshMode.script_from_file shell_kwargs["shell_type"] = "none" elif not sys.stdin.isatty() and not args.force_interactive: args.mode = XonshMode.script_from_stdin shell_kwargs["shell_type"] = "none" else: args.mode = XonshMode.interactive shell_kwargs["completer"] = True shell_kwargs["login"] = True env = start_services(shell_kwargs, args) env["XONSH_LOGIN"] = shell_kwargs["login"] if args.defines is not None: env.update([x.split("=", 1) for x in args.defines]) env["XONSH_INTERACTIVE"] = args.force_interactive or ( args.mode == XonshMode.interactive ) if ON_WINDOWS: setup_win_unicode_console(env.get("WIN_UNICODE_CONSOLE", True)) return args
def premain(argv=None): """Setup for main xonsh entry point. Returns parsed arguments.""" if argv is None: argv = sys.argv[1:] setup_timings() setproctitle = get_setproctitle() if setproctitle is not None: setproctitle(' '.join(['xonsh'] + argv)) builtins.__xonsh_ctx__ = {} args = parser.parse_args(argv) if args.help: parser.print_help() parser.exit() if args.version: version = '/'.join(('xonsh', __version__)) print(version) parser.exit() shell_kwargs = { 'shell_type': args.shell_type, 'completer': False, 'login': False, 'scriptcache': args.scriptcache, 'cacheall': args.cacheall, 'ctx': builtins.__xonsh_ctx__ } if args.login: shell_kwargs['login'] = True if args.norc: shell_kwargs['rc'] = () elif args.rc: shell_kwargs['rc'] = args.rc setattr(sys, 'displayhook', _pprint_displayhook) if args.command is not None: args.mode = XonshMode.single_command shell_kwargs['shell_type'] = 'none' elif args.file is not None: args.mode = XonshMode.script_from_file shell_kwargs['shell_type'] = 'none' elif not sys.stdin.isatty() and not args.force_interactive: args.mode = XonshMode.script_from_stdin shell_kwargs['shell_type'] = 'none' else: args.mode = XonshMode.interactive shell_kwargs['completer'] = True shell_kwargs['login'] = True env = start_services(shell_kwargs, args) env['XONSH_LOGIN'] = shell_kwargs['login'] if args.defines is not None: env.update([x.split('=', 1) for x in args.defines]) env['XONSH_INTERACTIVE'] = args.force_interactive or ( args.mode == XonshMode.interactive) if ON_WINDOWS: setup_win_unicode_console(env.get('WIN_UNICODE_CONSOLE', True)) return args
def premain(argv=None): """Setup for main xonsh entry point. Returns parsed arguments.""" if argv is None: argv = sys.argv[1:] builtins.__xonsh__ = XonshSession() setup_timings(argv) setproctitle = get_setproctitle() if setproctitle is not None: setproctitle(" ".join(["xonsh"] + argv)) args = parser.parse_args(argv) if args.help: parser.print_help() parser.exit() shell_kwargs = { "shell_type": args.shell_type, "completer": False, "login": False, "scriptcache": args.scriptcache, "cacheall": args.cacheall, "ctx": builtins.__xonsh__.ctx, } if args.login or sys.argv[0].startswith("-"): args.login = True shell_kwargs["login"] = True if args.norc: shell_kwargs["rc"] = () elif args.rc: shell_kwargs["rc"] = args.rc setattr(sys, "displayhook", _pprint_displayhook) if args.command is not None: args.mode = XonshMode.single_command shell_kwargs["shell_type"] = "none" elif args.file is not None: args.mode = XonshMode.script_from_file shell_kwargs["shell_type"] = "none" elif not sys.stdin.isatty() and not args.force_interactive: args.mode = XonshMode.script_from_stdin shell_kwargs["shell_type"] = "none" else: args.mode = XonshMode.interactive shell_kwargs["completer"] = True shell_kwargs["login"] = True pre_env = { "XONSH_LOGIN": shell_kwargs["login"], "XONSH_INTERACTIVE": args.force_interactive or (args.mode == XonshMode.interactive), } env = start_services(shell_kwargs, args, pre_env=pre_env) if args.defines is not None: env.update([x.split("=", 1) for x in args.defines]) return args
def premain(argv=None): """Setup for main xonsh entry point. Returns parsed arguments.""" if argv is None: argv = sys.argv[1:] setup_timings() setproctitle = get_setproctitle() if setproctitle is not None: setproctitle(' '.join(['xonsh'] + argv)) builtins.__xonsh_ctx__ = {} args = parser.parse_args(argv) if args.help: parser.print_help() parser.exit() if args.version: version = '/'.join(('xonsh', __version__)) print(version) parser.exit() shell_kwargs = {'shell_type': args.shell_type, 'completer': False, 'login': False, 'scriptcache': args.scriptcache, 'cacheall': args.cacheall, 'ctx': builtins.__xonsh_ctx__} if args.login: shell_kwargs['login'] = True if args.norc: shell_kwargs['rc'] = () elif args.rc: shell_kwargs['rc'] = args.rc setattr(sys, 'displayhook', _pprint_displayhook) if args.command is not None: args.mode = XonshMode.single_command shell_kwargs['shell_type'] = 'none' elif args.file is not None: args.mode = XonshMode.script_from_file shell_kwargs['shell_type'] = 'none' elif not sys.stdin.isatty() and not args.force_interactive: args.mode = XonshMode.script_from_stdin shell_kwargs['shell_type'] = 'none' else: args.mode = XonshMode.interactive shell_kwargs['completer'] = True shell_kwargs['login'] = True env = start_services(shell_kwargs) env['XONSH_LOGIN'] = shell_kwargs['login'] if args.defines is not None: env.update([x.split('=', 1) for x in args.defines]) env['XONSH_INTERACTIVE'] = args.force_interactive if ON_WINDOWS: setup_win_unicode_console(env.get('WIN_UNICODE_CONSOLE', True)) return args