Skip to content

Commit

Permalink
[next] Support recommending similar E2E scenarios based on the recent…
Browse files Browse the repository at this point in the history
… multiple execution commands (#5463)
  • Loading branch information
ReaNAiveD authored Dec 30, 2022
1 parent fb5f365 commit af60b6f
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 160 deletions.
5 changes: 5 additions & 0 deletions src/next/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.1.3
++++++
* Support recommending similar E2E scenarios based on the recent multiple execution commands
* Add new parameters `--scenario/-s` and `--command/-c` to support specifying recommendation type (command recommendation or scenario recommendation)

0.1.2
++++++
* Fix the bug that the nested command history could not be logged
Expand Down
8 changes: 4 additions & 4 deletions src/next/azext_next/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import threading

from azure.cli.core import AzCommandsLoader

from azext_next._help import helps # pylint: disable=unused-import
import threading


class NextCommandsLoader(AzCommandsLoader):

_instance_lock = threading.Lock()
_has_reload_command_table = False

def __new__(cls, cli_ctx=None):
def __new__(cls, cli_ctx=None): # pylint: disable=unused-argument
if not hasattr(NextCommandsLoader, "_instance"):
with NextCommandsLoader._instance_lock:
if not hasattr(NextCommandsLoader, "_instance"):
Expand All @@ -25,8 +26,7 @@ def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
next_custom = CliCommandType(
operations_tmpl='azext_next.custom#{}')
super(NextCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=next_custom)
super().__init__(cli_ctx=cli_ctx, custom_command_type=next_custom)

# Because the help content of other modules needs to be loaded when executing "az next"
# So modify the environment variable AZURE_CORE_USE_COMMAND_INDEX=False, and then reload the command table
Expand Down
15 changes: 9 additions & 6 deletions src/next/azext_next/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@
[1] az config set next.execute_in_prompt=True/False
Turn on/off the step of executing recommended commands in interactive mode. Turn on by default.
[2] az config set next.filter_type=True/False
Turn on/off the step of filtering recommendation type. Turn off by default.
[2] az config set next.recommended_type=all/scenario/command
Set the default recommended type. All is the default.
[3] az config set next.output=json/jsonc/none/table/tsv/yaml/yamlc/status
Set default output format. Status is the default.
[4] az config set next.num_limit={amount_limit}
Set the limit of recommended items. 5 is the default.
[4] az config set next.command_num_limit={command_amount_limit}
Set the limit of recommended command items. 5 is the default.
[5] az config set next.show_arguments=True/False
[5] az config set next.scenario_num_limit={scenario_amount_limit}
Set the limit of recommended scenario items. 5 is the default.
[6] az config set next.show_arguments=True/False
Show/hide the arguments of recommended items. False is the default.
[6] az config set next.print_help=True/False
[7] az config set next.print_help=True/False
Enable/disable whether to print help actively before executing each command. False is the default.
"""
4 changes: 3 additions & 1 deletion src/next/azext_next/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@


def load_arguments(self, _): # pylint: disable=unused-argument
pass
with self.argument_context('next') as c:
c.argument('scenario_only', options_list=['--scenario', '-s'], action='store_true', help='Specify this parameter will only recommend E2E scenarios')
c.argument('command_only', options_list=['--command', '-c'], action='store_true', help='Specify this parameter will only recommend commands')
10 changes: 10 additions & 0 deletions src/next/azext_next/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ class RecommendType(int, Enum):
Solution = 2
Command = 3
Scenario = 4

@staticmethod
def get(name):
if name.lower() == "solution":
return RecommendType.Solution
if name.lower() == "command":
return RecommendType.Command
if name.lower() == "scenario":
return RecommendType.Scenario
return RecommendType.All
Loading

0 comments on commit af60b6f

Please sign in to comment.