diff --git a/src/azure-cli-core/HISTORY.rst b/src/azure-cli-core/HISTORY.rst index 0e7fdfb271d..2d4449c53ee 100644 --- a/src/azure-cli-core/HISTORY.rst +++ b/src/azure-cli-core/HISTORY.rst @@ -3,6 +3,8 @@ Release History =============== +* Plug in HaTS survey + 2.0.77 ++++++ * Add deprecate message for Python 2.7 diff --git a/src/azure-cli-core/azure/cli/core/__init__.py b/src/azure-cli-core/azure/cli/core/__init__.py index f16ce9d976c..a981659928b 100644 --- a/src/azure-cli-core/azure/cli/core/__init__.py +++ b/src/azure-cli-core/azure/cli/core/__init__.py @@ -85,6 +85,7 @@ def get_cli_version(self): def show_version(self): from azure.cli.core.util import get_az_version_string + from azure.cli.core.commands.constants import SURVEY_PROMPT ver_string, updates_available = get_az_version_string() print(ver_string) if updates_available == -1: @@ -96,6 +97,8 @@ def show_version(self): else: print('Your CLI is up-to-date.') + print('\n' + SURVEY_PROMPT) + def exception_handler(self, ex): # pylint: disable=no-self-use from azure.cli.core.util import handle_exception return handle_exception(ex) diff --git a/src/azure-cli-core/azure/cli/core/_help.py b/src/azure-cli-core/azure/cli/core/_help.py index 990191782d5..7a01e570ee4 100644 --- a/src/azure-cli-core/azure/cli/core/_help.py +++ b/src/azure-cli-core/azure/cli/core/_help.py @@ -7,6 +7,7 @@ import argparse from azure.cli.core.commands import ExtensionCommandSource +from azure.cli.core.commands.constants import SURVEY_PROMPT from knack.help import (HelpFile as KnackHelpFile, CommandHelpFile as KnackCommandHelpFile, GroupHelpFile as KnackGroupHelpFile, ArgumentGroupRegistry as KnackArgumentGroupRegistry, @@ -150,6 +151,7 @@ def new_normalize_text(s): def show_help(self, cli_name, nouns, parser, is_group): self.update_loaders_with_help_file_contents(nouns) super(AzCliHelp, self).show_help(cli_name, nouns, parser, is_group) + print(SURVEY_PROMPT) def _register_help_loaders(self): import azure.cli.core._help_loaders as help_loaders diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index 0873dd081e0..8c68c1788a8 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -782,6 +782,7 @@ def find_from_user_account(self, username, password, tenant, resource): return result def find_through_authorization_code_flow(self, tenant, resource, authority_url): + from azure.cli.core.commands.constants import SURVEY_PROMPT # launch browser and get the code results = _get_authorization_code(resource, authority_url) @@ -793,6 +794,7 @@ def find_through_authorization_code_flow(self, tenant, resource, authority_url): token_entry = context.acquire_token_with_authorization_code(results['code'], results['reply_url'], resource, _CLIENT_ID, None) self.user_id = token_entry[_TOKEN_ENTRY_USER_ID] + print(SURVEY_PROMPT + "\n") logger.warning("You have logged in. Now let us find all the subscriptions to which you have access...") if tenant is None: result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource) diff --git a/src/azure-cli-core/azure/cli/core/commands/constants.py b/src/azure-cli-core/azure/cli/core/commands/constants.py index 5e02f5df12d..ed9dfe710fb 100644 --- a/src/azure-cli-core/azure/cli/core/commands/constants.py +++ b/src/azure-cli-core/azure/cli/core/commands/constants.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +from colorama import Fore, Style from knack.parser import ARGPARSE_SUPPORTED_KWARGS @@ -29,3 +30,6 @@ DEFAULT_QUERY_TIME_RANGE = 3600000 BLACKLISTED_MODS = ['context', 'shell', 'documentdb', 'component'] + +SURVEY_PROMPT = Fore.YELLOW + Style.BRIGHT + 'Please let us know how we are doing: ' + Fore.BLUE \ + + 'https://aka.ms/clihats' + Style.RESET_ALL diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index a5fa4817724..fc6ebd70c11 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -22,6 +22,7 @@ Release History **Core** * Remove support for Python 3.4 +* Plug in HaTS survey in multiple commands **Install** diff --git a/src/azure-cli/azure/cli/command_modules/feedback/custom.py b/src/azure-cli/azure/cli/command_modules/feedback/custom.py index 5b509ce0a84..7a2bc0baed1 100644 --- a/src/azure-cli/azure/cli/command_modules/feedback/custom.py +++ b/src/azure-cli/azure/cli/command_modules/feedback/custom.py @@ -24,6 +24,7 @@ from azure.cli.core.extension._resolve import resolve_project_url_from_index, NoExtensionCandidatesError from azure.cli.core.util import get_az_version_string, open_page_in_browser, can_launch_browser, in_cloud_console from azure.cli.core.azlogging import _UNKNOWN_COMMAND, _CMD_LOG_LINE_PREFIX +from azure.cli.core.commands.constants import SURVEY_PROMPT _ONE_MIN_IN_SECS = 60 @@ -50,7 +51,8 @@ '\nWe appreciate your feedback!\n\n' \ 'For more information on getting started, visit: {}\n' \ 'If you have questions, visit our Stack Overflow page: {}\n'\ - .format(_GET_STARTED_URL, _QUESTIONS_URL) + '{}\n'\ + .format(_GET_STARTED_URL, _QUESTIONS_URL, SURVEY_PROMPT) _MSG_CMD_ISSUE = "\nEnter the number of the command you would like to create an issue for. Enter q to quit: " diff --git a/src/azure-cli/azure/cli/command_modules/find/custom.py b/src/azure-cli/azure/cli/command_modules/find/custom.py index ab1b97f5391..19951443459 100644 --- a/src/azure-cli/azure/cli/command_modules/find/custom.py +++ b/src/azure-cli/azure/cli/command_modules/find/custom.py @@ -15,6 +15,7 @@ from azure.cli.core import telemetry as telemetry_core from azure.cli.core import __version__ as core_version +from azure.cli.core.commands.constants import SURVEY_PROMPT from pkg_resources import parse_version from knack.log import get_logger logger = get_logger(__name__) @@ -65,6 +66,7 @@ def process_query(cli_term): 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")) + print(SURVEY_PROMPT) def style_message(msg):