From f42c965da44be6940134b805edb54c5eca37d9ae Mon Sep 17 00:00:00 2001 From: ZYX Date: Mon, 27 Feb 2023 14:39:38 -0500 Subject: [PATCH] fix(aliases): clarify how to pass in keywords to `acs` (#11521) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/aliases/README.md | 2 +- plugins/aliases/cheatsheet.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md index 4e77f67b3..6a2da3d74 100644 --- a/plugins/aliases/README.md +++ b/plugins/aliases/README.md @@ -19,7 +19,7 @@ Requirements: Python needs to be installed. - `acs -h/--help`: print help mesage -- `acs `: filter aliases by `` and highlight +- `acs `: filter and highlight aliases by `` - `acs -g /--group `: show only aliases for group ``. Multiple uses of the flag show all groups diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py index 3362a6ab6..fb8c74aa4 100644 --- a/plugins/aliases/cheatsheet.py +++ b/plugins/aliases/cheatsheet.py @@ -51,18 +51,18 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False): continue aliases = cheatsheet.get(key) if not wfilter: - pretty_print_group(key, aliases, wfilter, groups_only) + pretty_print_group(key, aliases, only_groupname=groups_only) else: - pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter) + pretty_print_group(key, [ alias for alias in aliases if wfilter in alias[0] or wfilter in alias[1] ], wfilter) if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Pretty print aliases.") - parser.add_argument('filter', nargs="*", help="search aliases matching string") + parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs") + parser.add_argument('filter', nargs="*", metavar="", help="search aliases matching keywords") parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups") parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups") args = parser.parse_args() lines = sys.stdin.readlines() group_list = args.group_list or None - wfilter = " ".join(args.filter) or None + wfilter = " ".join(args.filter[1:]) if args.filter else None pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only)