Beispiel #1
0
def process_query(cli_term):
    if not cli_term:
        logger.error('Please provide a search term e.g. az find "vm"')
    else:
        print(random.choice(WAIT_MESSAGE), file=sys.stderr)
        response = call_aladdin_service(cli_term)

        if response.status_code != 200:
            logger.error('Unexpected Error: If it persists, please file a bug.')
        else:
            if (platform.system() == 'Windows' and should_enable_styling()):
                colorama.init(convert=True)
            has_pruned_answer = False
            answer_list = json.loads(response.content)
            if not answer_list:
                print("\nSorry I am not able to help with [" + cli_term + "]."
                      "\nTry typing the beginning of a command e.g. " + style_message('az vm') + ".", file=sys.stderr)
            else:
                if answer_list[0]['source'] == 'pruned':
                    has_pruned_answer = True
                    answer_list.pop(0)
                print("\nHere are the most common ways to use [" + cli_term + "]: \n", file=sys.stderr)

                for answer in answer_list:
                    cleaned_answer = clean_from_http_answer(answer)
                    print(style_message(cleaned_answer.title))
                    print(cleaned_answer.snippet + '\n')
                if has_pruned_answer:
                    print(style_message("More commands and examples are available in the latest version of the CLI. "
                                        "Please update for the best experience.\n"))
    from azure.cli.core.util import show_updates_available
    show_updates_available(new_line_after=True)
    print(SURVEY_PROMPT)
Beispiel #2
0
def handle_feedback(cmd):
    try:
        print(_MSG_INTR)
        recent_commands = _display_recent_commands(cmd)
        res = _prompt_issue(recent_commands)

        if res:
            print(_MSG_THNK)
            from azure.cli.core.util import show_updates_available
            show_updates_available(new_line_before=True)
        return
    except NoTTYException:
        raise CLIError('This command is interactive, however no tty is available.')
    except (EOFError, KeyboardInterrupt):
        print()
Beispiel #3
0
    def show_help(self, cli_name, nouns, parser, is_group):
        self.update_loaders_with_help_file_contents(nouns)

        delimiters = ' '.join(nouns)
        help_file = self.command_help_cls(self, delimiters, parser) if not is_group \
            else self.group_help_cls(self, delimiters, parser)
        help_file.load(parser)
        if not nouns:
            help_file.command = ''
        else:
            AzCliHelp.update_examples(help_file)
        self._print_detailed_help(cli_name, help_file)
        from azure.cli.core.util import show_updates_available
        show_updates_available(new_line_after=True)
        show_link = self.cli_ctx.config.getboolean('output',
                                                   'show_survey_link', True)
        if show_link:
            print(SURVEY_PROMPT_COLOR if self.cli_ctx.
                  enable_color else SURVEY_PROMPT)
            if not nouns:
                print(UX_SURVEY_PROMPT_COLOR if self.cli_ctx.
                      enable_color else UX_SURVEY_PROMPT)