on master help sign in
Syntax: add cmd-help (#2148)

* Add cmd-help syntax To highlight command --help messages. * README.md: mention help message highlighting * README.md: edit help message highlighting

commitb0898900ce0d1e70a7c1e805a1bcfce7d1e2b824 authorVíctor González Prieto <victor.gp.dev@gmail.com> dateTue 26 Apr 2022, 19:42 (5 years ago) parent3239d3b
6 files changed+133
.gitmodules+5 CHANGELOG.md+1 README.md+18 assets/syntaxes/02_Extra/cmd-help+1 tests/syntax-tests/highlighted/cmd-help/test.cmd-help+54 tests/syntax-tests/source/cmd-help/test.cmd-help+54
.gitmodules+5
@@ -239,3 +239,8 @@
239239[submodule "assets/syntaxes/02_Extra/SublimeJQ"]
240240 path = assets/syntaxes/02_Extra/SublimeJQ
241241 url = https://github.com/zogwarg/SublimeJQ.git
242+[submodule "assets/syntaxes/02_Extra/cmd-help"]
243+ path = assets/syntaxes/02_Extra/cmd-help
244+ url = https://github.com/victor-gp/cmd-help-sublime-syntax.git
245+ branch = main
246+ shallow = true
CHANGELOG.md+1
@@ -16,6 +16,7 @@
1616
1717- Mapped clang-format config file (.clang-format) to YAML syntax (@TruncatedDinosour)
1818- log syntax: improved handling of escape characters in double quoted strings. See #2123 (@keith-hall)
19+- Added cmd-help syntax to scope --help messages. See #2148 (@victor-gp)
1920
2021## Themes
2122
README.md+18
@@ -212,6 +212,24 @@ Also, note that this will [not work](https://github.com/sharkdp/bat/issues/1145)
212212
213213The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.md) script is a wrapper that will format code and print it with `bat`.
214214
215+#### Highlighting `--help` messages
216+
217+You can use `bat` to colorize help text: `$ cp --help | bat -plhelp`
218+
219+You can also use a wrapper around this:
220+
221+```bash
222+# in your .bashrc/.zshrc/*rc
223+alias bathelp='bat --plain --language=help'
224+help() {
225+ "$@" --help 2>&1 | bathelp
226+}
227+```
228+
229+Then you can do `$ help cp` or `$ help git commit`.
230+
231+Please report any issues with the help syntax in [this repository](https://github.com/victor-gp/cmd-help-sublime-syntax).
232+
215233
216234## Installation
217235
assets/syntaxes/02_Extra/cmd-helpnew file+1

Submodule changed.

tests/syntax-tests/highlighted/cmd-help/test.cmd-helpnew file+54
@@ -0,0 +1,54 @@
1+bat 0.20.0 (e735562-modified)
2+A cat(1) clone with syntax highlighting and Git integration.
3+
4+USAGE:
5+ bat [OPTIONS] [FILE]...
6+ bat <SUBCOMMAND>
7+
8+OPTIONS:
9+ -A, --show-all
10+ Show non-printable characters (space, tab, newline, ..).
11+
12+ -p, --plain Show plain style (alias for '--style=plain').
13+ -l, --language <language> Set the language for syntax highlighting.
14+ -H, --highlight-line <N:M>... Highlight lines N through M.
15+ --file-name <name>... Specify the name to display for a file.
16+ -d, --diff
17+ Only show lines that have been added/removed/modified.
18+
19+ --tabs <T> Set the tab width to T spaces.
20+ --wrap <mode>
21+ Specify the text-wrapping mode (*auto*, never, character).
22+
23+ -n, --number
24+ Show line numbers (alias for '--style=numbers').
25+
26+ --color <when> When to use colors (*auto*, never, always).
27+ --italic-text <when> Use italics in output (always, *never*)
28+ --decorations <when>
29+ When to show the decorations (*auto*, never, always).
30+
31+ --paging <when>
32+ Specify when to use the pager, or use `-P` to disable (*auto*, never,
33+ always).
34+ -m, --map-syntax <glob:syntax>...
35+ Use the specified syntax for files matching the glob pattern
36+ ('*.cpp:C++').
37+ --theme <theme> Set the color theme for syntax highlighting.
38+ --list-themes Display all supported highlighting themes.
39+ --style <components>
40+ Comma-separated list of style elements to display (*auto*, full, plain,
41+ changes, header, grid, rule, numbers, snip).
42+ -r, --line-range <N:M>... Only print the lines from N to M.
43+ -L, --list-languages Display all supported languages.
44+ -h, --help Print this help message.
45+ -V, --version Show version information.
46+
47+ARGS:
48+ <FILE>... File(s) to print / concatenate. Use '-' for standard input.
49+
50+SUBCOMMANDS:
51+ cache Modify the syntax-definition and theme cache
52+
53+Note: `bat -h` prints a short and concise overview while `bat --help` gives all
54+details.
tests/syntax-tests/source/cmd-help/test.cmd-helpnew file+54
@@ -0,0 +1,54 @@
1+bat 0.20.0 (e735562-modified)
2+A cat(1) clone with syntax highlighting and Git integration.
3+
4+USAGE:
5+ bat [OPTIONS] [FILE]...
6+ bat <SUBCOMMAND>
7+
8+OPTIONS:
9+ -A, --show-all
10+ Show non-printable characters (space, tab, newline, ..).
11+
12+ -p, --plain Show plain style (alias for '--style=plain').
13+ -l, --language <language> Set the language for syntax highlighting.
14+ -H, --highlight-line <N:M>... Highlight lines N through M.
15+ --file-name <name>... Specify the name to display for a file.
16+ -d, --diff
17+ Only show lines that have been added/removed/modified.
18+
19+ --tabs <T> Set the tab width to T spaces.
20+ --wrap <mode>
21+ Specify the text-wrapping mode (*auto*, never, character).
22+
23+ -n, --number
24+ Show line numbers (alias for '--style=numbers').
25+
26+ --color <when> When to use colors (*auto*, never, always).
27+ --italic-text <when> Use italics in output (always, *never*)
28+ --decorations <when>
29+ When to show the decorations (*auto*, never, always).
30+
31+ --paging <when>
32+ Specify when to use the pager, or use `-P` to disable (*auto*, never,
33+ always).
34+ -m, --map-syntax <glob:syntax>...
35+ Use the specified syntax for files matching the glob pattern
36+ ('*.cpp:C++').
37+ --theme <theme> Set the color theme for syntax highlighting.
38+ --list-themes Display all supported highlighting themes.
39+ --style <components>
40+ Comma-separated list of style elements to display (*auto*, full, plain,
41+ changes, header, grid, rule, numbers, snip).
42+ -r, --line-range <N:M>... Only print the lines from N to M.
43+ -L, --list-languages Display all supported languages.
44+ -h, --help Print this help message.
45+ -V, --version Show version information.
46+
47+ARGS:
48+ <FILE>... File(s) to print / concatenate. Use '-' for standard input.
49+
50+SUBCOMMANDS:
51+ cache Modify the syntax-definition and theme cache
52+
53+Note: `bat -h` prints a short and concise overview while `bat --help` gives all
54+details.