Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{Core} Fix help message format for AAZGenericUpdate #29898

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/azure-cli-core/azure/cli/core/aaz/_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -626,12 +627,11 @@ def _build_cmd_action(self):


class AAZGenericUpdateSetArg(AAZGenericUpdateArg):
_example = '--set property1.property2=<value>'

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,
Expand All @@ -653,12 +653,11 @@ class Action(AAZGenericUpdateAction):


class AAZGenericUpdateAddArg(AAZGenericUpdateArg):
_example = '--add property.listProperty <key=value, string or JSON string>'

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,
Expand All @@ -680,12 +679,11 @@ class Action(AAZGenericUpdateAction):


class AAZGenericUpdateRemoveArg(AAZGenericUpdateArg):
_example = '--remove property.list <indexToRemove> 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,
Expand Down
14 changes: 14 additions & 0 deletions src/azure-cli-core/azure/cli/core/tests/test_aaz_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <key=value, string or JSON string>`')
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=<value>`')
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 <indexToRemove>` OR `--remove propertyToRemove`')


class TestAAZArgUtils(unittest.TestCase):

Expand Down
Loading