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
评论列表
文章目录