Repository: StackStorm/st2

Issue:
Matching action alias for 'pack install xxx' returns an error
##### SUMMARY

Noticed by `@ravi` on Slack.

When running `st2 action-alias match 'pack install vsphere'` multiple action-aliases are matched, causing an error.

This is confusing in two ways: 
1) Running that action-alias should not be ambiguous
2) The help message for `st2 action-alias match` says it returns a list of matching aliases, but instead it either returns one or it errors.

##### ISSUE TYPE
 - Bug Report

##### STACKSTORM VERSION
```shell
$ st2 --version
st2 2.10.1, on Python 2.7.5
```

##### OS / ENVIRONMENT / INSTALL METHOD
```shell
# OS
$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.6 (Maipo)

# Install method
puppet-st2
```

##### STEPS TO REPRODUCE
```shell
$ st2 action-alias match 'pack install vsphere'
```

##### EXPECTED RESULTS
```shell
$ st2 action-alias match 'pack install vsphere'
+--------------+-----------------------------------+
| name         | description                       |
+--------------+-----------------------------------+
| pack_install | Install/upgrade StackStorm packs. |
+--------------+-----------------------------------+
```

##### ACTUAL RESULTS
```shell
$ st2 action-alias match 'pack install vsphere'
ERROR: 400 Client Error: Bad Request
MESSAGE: Command 'pack install vsphere' matched more than 1 pattern for url: http://127.0.0.1:9101/v1/actionalias/match
```

This is also confusing because `st2 action-alias match --help` says it should return a list of matching aliases, when instead it either returns a single alias or it errors out if multiple are found.

```shell
$ st2 action-alias match --help
usage: st2 action-alias match [-h] [-t TOKEN] [--api-key API_KEY] [-j] [-y]
                              [-a ATTR [ATTR ...]] [-w WIDTH [WIDTH ...]]
                              command

Get the list of action aliases that match the command text.
```

##### INVESTIGATION

It appears that the action-alias `packs.pack_install` has redundant patterns defined: https://github.com/StackStorm/st2/blob/master/contrib/packs/aliases/pack_install.yaml#L7-L12

I think the simplest fix is to remove the redundant pattern and change the display text for the one that is left behind.


Discussion:

Resolving patch:
diff --git a/st2client/st2client/commands/action_alias.py b/st2client/st2client/commands/action_alias.py
--- a/st2client/st2client/commands/action_alias.py
+++ b/st2client/st2client/commands/action_alias.py
@@ -63,13 +63,13 @@ class ActionAliasMatchCommand(resource.ResourceCommand):
     def __init__(self, resource, *args, **kwargs):
         super(ActionAliasMatchCommand, self).__init__(
             resource, 'match',
-            'Get the list of %s that match the command text.' %
-            resource.get_plural_display_name().lower(),
+            'Get the %s that match the command text.' %
+            resource.get_display_name().lower(),
             *args, **kwargs)
 
         self.parser.add_argument('match_text',
                                  metavar='command',
-                                 help=('Get the list of %s that match the command text.' %
+                                 help=('Get the %s that match the command text.' %
                                        resource.get_display_name().lower()))
         self.parser.add_argument('-a', '--attr', nargs='+',
                                  default=self.display_attributes,


Test patch: