From 05c345f3a4167d3116d7261996662071f802b69b Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 10 Jul 2023 18:24:32 +0200 Subject: [PATCH] fix --resources [all] Allow passing `-r` without argument to display all resources. Ref: #81 Co-authored-by: tomasohara --- README.md | 6 +++--- colout/colout.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9d51e02..10bde37 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ colout — Color Up Arbitrary Command Output ## Synopsis -`colout [-h] [-r RESOURCE]` +`colout [-h] [-r [RESOURCE]]` `colout [-g] [-c] [-l min,max] [-a] [-t] [-T DIR] [-P DIR] [-d COLORMAP] [-s] [-e CHAR] [-E CHAR] [--debug] PATTERN [COLOR(S) [STYLE(S)]]` @@ -145,10 +145,10 @@ $ sudo apt-get/aptitude install colout Also, external palettes are converted from RGB to 256-ANSI and will thus not work if you use them as default colormaps for a 8-colors mode special color. -* `-r TYPE(S)`, `--resources TYPE(S)`: +* `-r [TYPE(S)]`, `--resources [TYPE(S)]`: Print the names of available resources. Use a comma-separated list of resources names (styles, colors, special, themes, palettes, colormaps or lexers), - use 'all' to print everything. + use 'all' (or no argument) to print all resources. * `-s`, `--source`: Interpret PATTERN as source code readable by the Pygments library. If the first letter of PATTERN diff --git a/colout/colout.py b/colout/colout.py index 85ed7b0..b7fd863 100755 --- a/colout/colout.py +++ b/colout/colout.py @@ -889,6 +889,10 @@ def _args_parse(argv, usage=""): parser.add_argument("--debug", action="store_true", help="Debug mode: print what's going on internally, useful if you want to check what features are available.") + # HACK: Mock up "--resources ALL" if just "--resources" on command line + if (len(sys.argv) == 2 and (sys.argv[1] in ["-r", "--resources"])): + sys.argv.append("ALL") + args = parser.parse_args() return args.pattern[0], args.color, args.style, args.groups, \