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(): """ the main function """ 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 = CONFIGURATION if config.BOOLEAN_STATES[config.config.get('DEFAULT', 'firsttime')]: APPLICATION.execute(["configure"]) print("When in doubt, ask for 'help'") config.firsttime() shell_app = Shell( completer=AZCOMPLETER, lexer=AzLexer, history=FileHistory(os.path.join(CONFIGURATION.get_config_dir(), config.get_history())), app=APPLICATION, # cli_config=os.path.join(azure_folder, 'config') ) 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 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()