diff --git a/src/azure-cli-core/azure/cli/core/aaz/_arg.py b/src/azure-cli-core/azure/cli/core/aaz/_arg.py index 324c8893608..14553b2048d 100644 --- a/src/azure-cli-core/azure/cli/core/aaz/_arg.py +++ b/src/azure-cli-core/azure/cli/core/aaz/_arg.py @@ -6,6 +6,7 @@ import copy from azure.cli.core import azclierror +from azure.cli.core.commands.arm import add_usage, remove_usage, set_usage from knack.arguments import CLICommandArgument, CaseInsensitiveList from knack.preview import PreviewItem from knack.experimental import ExperimentalItem @@ -626,12 +627,11 @@ def _build_cmd_action(self): class AAZGenericUpdateSetArg(AAZGenericUpdateArg): - _example = '--set property1.property2=' def __init__( self, options=('--set',), arg_group='Generic Update', help='Update an object by specifying a property path and value to set.' - ' Example: {}'.format(_example), + ' Example: {}'.format(set_usage), **kwargs): super().__init__( options=options, @@ -653,12 +653,11 @@ class Action(AAZGenericUpdateAction): class AAZGenericUpdateAddArg(AAZGenericUpdateArg): - _example = '--add property.listProperty ' def __init__( self, options=('--add',), arg_group='Generic Update', help='Add an object to a list of objects by specifying a path and key value pairs.' - ' Example: {}'.format(_example), + ' Example: {}'.format(add_usage), **kwargs): super().__init__( options=options, @@ -680,12 +679,11 @@ class Action(AAZGenericUpdateAction): class AAZGenericUpdateRemoveArg(AAZGenericUpdateArg): - _example = '--remove property.list OR --remove propertyToRemove' def __init__( self, options=('--remove', ), arg_group='Generic Update', help='Remove a property or an element from a list.' - ' Example: {}'.format(_example), + ' Example: {}'.format(remove_usage), **kwargs): super().__init__( options=options, diff --git a/src/azure-cli-core/azure/cli/core/tests/test_aaz_arg.py b/src/azure-cli-core/azure/cli/core/tests/test_aaz_arg.py index 1afe6f372d2..bbf6f2b868a 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_aaz_arg.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_aaz_arg.py @@ -1435,6 +1435,20 @@ def test_aaz_configured_default_arg(self): arg = schema.count.to_cmd_arg("count") self.assertEqual(arg.type.settings['configured_default'], 'specialcount') + def test_aaz_generic_update_arg(self): + from azure.cli.core.aaz._arg import (AAZGenericUpdateAddArg, AAZGenericUpdateSetArg, AAZGenericUpdateRemoveArg, + AAZArgumentsSchema) + schema = AAZArgumentsSchema() + schema.generic_update_add = AAZGenericUpdateAddArg() + schema.generic_update_set = AAZGenericUpdateSetArg() + schema.generic_update_remove = AAZGenericUpdateRemoveArg() + arg = schema.generic_update_add.to_cmd_arg("add") + self.assertEqual(arg.type.settings['help'], 'Add an object to a list of objects by specifying a path and key value pairs. Example: `--add property.listProperty `') + arg = schema.generic_update_set.to_cmd_arg("set") + self.assertEqual(arg.type.settings['help'], 'Update an object by specifying a property path and value to set. Example: `--set property1.property2=`') + arg = schema.generic_update_remove.to_cmd_arg("remove") + self.assertEqual(arg.type.settings['help'], 'Remove a property or an element from a list. Example: `--remove property.list ` OR `--remove propertyToRemove`') + class TestAAZArgUtils(unittest.TestCase):