def main(style=None): os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ azure_folder = cli_config_dir() if not os.path.exists(azure_folder): os.makedirs(azure_folder) ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) CONFIG.load(os.path.join(azure_folder, 'az.json')) SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600) config = SHELL_CONFIGURATION shell_config_dir = azclishell.configuration.get_config_dir if style: given_style = style config.set_style(given_style) else: given_style = config.get_style() style_obj = style_factory(given_style) if config.BOOLEAN_STATES[config.config.get('DEFAULT', 'firsttime')]: print("When in doubt, ask for 'help'") config.firsttime() shell_app = Shell(completer=AZCOMPLETER, lexer=AzLexer, history=FileHistory( os.path.join(shell_config_dir(), config.get_history())), app=APPLICATION, styles=style_obj) shell_app.run()
def main(style=None): if APPLICATION.session["az_interactive_active"]: logger.warning("You're in the interactive shell already.\n") return os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ azure_folder = cli_config_dir() if not os.path.exists(azure_folder): os.makedirs(azure_folder) ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) CONFIG.load(os.path.join(azure_folder, 'az.json')) SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600) config = azclishell.configuration.CONFIGURATION shell_config_dir = azclishell.configuration.get_config_dir try: commands = GatherCommands() az_completer = AzCompleter(commands) except IOError: # if there is no cache az_completer = None if style: given_style = style config.set_style(given_style) else: given_style = config.get_style() style_obj = style_factory(given_style) if config.BOOLEAN_STATES[config.config.get('DEFAULT', 'firsttime')]: config.firsttime() ask_feedback = False if not config.has_feedback() and frequent_user: print( "\n\nAny comments or concerns? You can use the \'feedback\' command!" + " We would greatly appreciate it.\n") ask_feedback = True shell_app = Shell(completer=az_completer, lexer=AzLexer, history=FileHistory( os.path.join(shell_config_dir(), config.get_history())), app=APPLICATION, styles=style_obj, user_feedback=ask_feedback) shell_app.app.session["az_interactive_active"] = True shell_app.run() shell_app.app.session["az_interactive_active"] = False
def main(style=None): if APPLICATION.session["az_interactive_active"]: logger.warning("You're in the interactive shell already.\n") return os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ azure_folder = cli_config_dir() if not os.path.exists(azure_folder): os.makedirs(azure_folder) ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) CONFIG.load(os.path.join(azure_folder, 'az.json')) SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600) config = azclishell.configuration.CONFIGURATION shell_config_dir = azclishell.configuration.get_config_dir try: commands = GatherCommands() az_completer = AzCompleter(commands) except IOError: # if there is no cache az_completer = None if style: given_style = style config.set_style(given_style) else: given_style = config.get_style() style_obj = style_factory(given_style) if config.BOOLEAN_STATES[config.config.get('DEFAULT', 'firsttime')]: config.firsttime() ask_feedback = False if not config.has_feedback() and frequent_user: print("\n\nAny comments or concerns? You can use the \'feedback\' command!" + " We would greatly appreciate it.\n") ask_feedback = True shell_app = Shell( completer=az_completer, lexer=AzLexer, history=FileHistory( os.path.join(shell_config_dir(), config.get_history())), app=APPLICATION, styles=style_obj, user_feedback=ask_feedback ) shell_app.app.session["az_interactive_active"] = True shell_app.run() shell_app.app.session["az_interactive_active"] = False
def __init__(self, cli_ctx, style=None, completer=None, styles=None, lexer=None, history=InMemoryHistory(), app=None, input_custom=sys.stdin, output_custom=None, user_feedback=False, intermediate_sleep=.25, final_sleep=4): from azclishell.color_styles import style_factory self.cli_ctx = cli_ctx self.config = Configuration(cli_ctx.config, style=style) self.config.set_style(style) self.styles = style or style_factory(self.config.get_style()) self.lexer = lexer or get_az_lexer(self.config) if self.styles else None try: from azclishell.gather_commands import GatherCommands from azclishell.az_completer import AzCompleter self.completer = completer or AzCompleter(self, GatherCommands(self.config)) except IOError: # if there is no cache self.completer = None self.history = history or FileHistory(os.path.join(self.config.config_dir, self.config.get_history())) os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ self.telemetry = Telemetry(self.cli_ctx) # OH WHAT FUN TO FIGURE OUT WHAT THESE ARE! self._cli = None self.refresh_cli = False self.layout = None self.description_docs = u'' self.param_docs = u'' self.example_docs = u'' self._env = os.environ self.last = None self.last_exit = 0 self.user_feedback = user_feedback self.input = input_custom self.output = output_custom self.config_default = "" self.default_command = "" self.threads = [] self.curr_thread = None self.spin_val = -1 self.intermediate_sleep = intermediate_sleep self.final_sleep = final_sleep # try to consolidate state information here... # These came from key bindings... self._section = 1 self.is_prompting = False self.is_example_repl = False self.is_showing_default = False self.is_symbols = True
def main(style=None): os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ azure_folder = cli_config_dir() if not os.path.exists(azure_folder): os.makedirs(azure_folder) ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) CONFIG.load(os.path.join(azure_folder, 'az.json')) SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600) config = SHELL_CONFIGURATION shell_config_dir = azclishell.configuration.get_config_dir if style: given_style = style config.set_style(given_style) else: given_style = config.get_style() style_obj = style_factory(given_style) if config.BOOLEAN_STATES[config.config.get('DEFAULT', 'firsttime')]: print("When in doubt, ask for 'help'") config.firsttime() ask_feedback = False if not config.has_feedback() and frequent_user: print("\n\nAny comments or concerns? You can use the \'feedback\' command!" + " We would greatly appreciate it.\n") ask_feedback = True shell_app = Shell( completer=AZCOMPLETER, lexer=AzLexer, history=FileHistory( os.path.join(shell_config_dir(), config.get_history())), app=APPLICATION, styles=style_obj, user_feedback=ask_feedback ) shell_app.run()
def main(style=None): os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ azure_folder = cli_config_dir() if not os.path.exists(azure_folder): os.makedirs(azure_folder) ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) CONFIG.load(os.path.join(azure_folder, 'az.json')) SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600) config = SHELL_CONFIGURATION shell_config_dir = azclishell.configuration.get_config_dir if style: given_style = style config.set_style(given_style) else: given_style = config.get_style() style_obj = style_factory(given_style) if config.BOOLEAN_STATES[config.config.get('DEFAULT', 'firsttime')]: print("When in doubt, ask for 'help'") config.firsttime() ask_feedback = False if not config.has_feedback() and frequent_user: print( "\n\nAny comments or concerns? You can use the \'feedback\' command!" + " We would greatly appreciate it.\n") ask_feedback = True shell_app = Shell(completer=AZCOMPLETER, lexer=AzLexer, history=FileHistory( os.path.join(shell_config_dir(), config.get_history())), app=APPLICATION, styles=style_obj, user_feedback=ask_feedback) shell_app.run()
def main(args): os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ parser = argparse.ArgumentParser(prog='az-shell') parser.add_argument('--style', dest='style', help='the colors of the shell', choices=get_options()) args = parser.parse_args(args) azure_folder = cli_config_dir() if not os.path.exists(azure_folder): os.makedirs(azure_folder) ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) CONFIG.load(os.path.join(azure_folder, 'az.json')) SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600) config = SHELL_CONFIGURATION shell_config_dir = azclishell.configuration.get_config_dir if args.style: given_style = args.style config.set_style(given_style) else: given_style = config.get_style() style = style_factory(given_style) if config.BOOLEAN_STATES[config.config.get('DEFAULT', 'firsttime')]: print("When in doubt, ask for 'help'") config.firsttime() shell_app = Shell(completer=AZCOMPLETER, lexer=AzLexer, history=FileHistory( os.path.join(shell_config_dir(), config.get_history())), app=APPLICATION, styles=style) shell_app.run()