fix --resources [all]

Allow passing `-r` without argument to display all resources.

Ref: #81
Co-authored-by: tomasohara
This commit is contained in:
Johann Dreo 2023-07-10 18:24:32 +02:00
commit 05c345f3a4
2 changed files with 7 additions and 3 deletions

View file

@ -11,7 +11,7 @@ colout — Color Up Arbitrary Command Output
## Synopsis ## 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)]]` `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 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. 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 Print the names of available resources. Use a comma-separated list of resources names
(styles, colors, special, themes, palettes, colormaps or lexers), (styles, colors, special, themes, palettes, colormaps or lexers),
use 'all' to print everything. use 'all' (or no argument) to print all resources.
* `-s`, `--source`: * `-s`, `--source`:
Interpret PATTERN as source code readable by the Pygments library. If the first letter of PATTERN Interpret PATTERN as source code readable by the Pygments library. If the first letter of PATTERN

View file

@ -889,6 +889,10 @@ def _args_parse(argv, usage=""):
parser.add_argument("--debug", action="store_true", 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.") 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() args = parser.parse_args()
return args.pattern[0], args.color, args.style, args.groups, \ return args.pattern[0], args.color, args.style, args.groups, \