f42c965da44be6940134b805edb54c5eca37d9ae

Author
ZYX <yuxz@amazon.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(aliases): clarify how to pass in keywords to `acs` (#11521)

Co-authored-by: Marc Cornellà <hello@mcornella.com>

Diff

 1diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md
 2index 4e77f67b32a390c1ae80fc9cdc29040c59edb1cb..6a2da3d74ca700fc22c6776cdfb2399a9bb6dc7b 100644
 3--- a/plugins/aliases/README.md
 4+++ b/plugins/aliases/README.md
 5@@ -19,7 +19,7 @@ Requirements: Python needs to be installed.
 6 
 7 - `acs -h/--help`: print help mesage
 8 
 9-- `acs <keyword>`: filter aliases by `<keyword>` and highlight
10+- `acs <keyword(s)>`: filter and highlight aliases by `<keyword>`
11 
12 - `acs -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
13 
14diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py
15index 3362a6ab66fabc1c6b39aee8d3a6d35da01ac3f2..fb8c74aa4595644c24fad3ae751fdfd92978fa7f 100644
16--- a/plugins/aliases/cheatsheet.py
17+++ b/plugins/aliases/cheatsheet.py
18@@ -51,18 +51,18 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
19             continue
20         aliases = cheatsheet.get(key)
21         if not wfilter:
22-            pretty_print_group(key, aliases, wfilter, groups_only)
23+            pretty_print_group(key, aliases, only_groupname=groups_only)
24         else:
25-            pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
26+            pretty_print_group(key, [ alias for alias in aliases if wfilter in alias[0] or wfilter in alias[1] ], wfilter)
27 
28 if __name__ == '__main__':
29-    parser = argparse.ArgumentParser(description="Pretty print aliases.")
30-    parser.add_argument('filter', nargs="*", help="search aliases matching string")
31+    parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs")
32+    parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
33     parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
34     parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
35     args = parser.parse_args()
36 
37     lines = sys.stdin.readlines()
38     group_list = args.group_list or None
39-    wfilter = " ".join(args.filter) or None
40+    wfilter = " ".join(args.filter[1:]) if args.filter else None
41     pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only)