Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax: add cmd-help #2148

Merged
merged 3 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,8 @@
[submodule "assets/syntaxes/02_Extra/SublimeJQ"]
path = assets/syntaxes/02_Extra/SublimeJQ
url = https://github.com/zogwarg/SublimeJQ.git
[submodule "assets/syntaxes/02_Extra/cmd-help"]
path = assets/syntaxes/02_Extra/cmd-help
url = https://github.com/victor-gp/cmd-help-sublime-syntax.git
branch = main
shallow = true
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- Mapped clang-format config file (.clang-format) to YAML syntax (@TruncatedDinosour)
- log syntax: improved handling of escape characters in double quoted strings. See #2123 (@keith-hall)
- Added cmd-help syntax to scope --help messages. See #2148 (@victor-gp)

## Themes

Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,24 @@ Also, note that this will [not work](https://github.com/sharkdp/bat/issues/1145)

The [`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`.

#### Highlighting `--help` messages

You can use `bat` to colorize help text: `$ cp --help | bat -plhelp`

You can also use a wrapper around this:

```bash
# in your .bashrc/.zshrc/*rc
alias bathelp='bat --plain --language=help'
help() {
"$@" --help 2>&1 | bathelp
}
```

Then you can do `$ help cp` or `$ help git commit`.

Please report any issues with the help syntax in [this repository](https://github.com/victor-gp/cmd-help-sublime-syntax).


## Installation

Expand Down
1 change: 1 addition & 0 deletions assets/syntaxes/02_Extra/cmd-help
Submodule cmd-help added at 1e513f
54 changes: 54 additions & 0 deletions tests/syntax-tests/highlighted/cmd-help/test.cmd-help
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
bat 0.20.0 (e735562-modified)
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
 -A, --show-all
 Show non-printable characters (space, tab, newline, ..).

 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
 -H, --highlight-line <N:M>... Highlight lines N through M.
 --file-name <name>... Specify the name to display for a file.
 -d, --diff
 Only show lines that have been added/removed/modified.

 --tabs <T> Set the tab width to T spaces.
 --wrap <mode>
 Specify the text-wrapping mode (*auto*, never, character).

 -n, --number
 Show line numbers (alias for '--style=numbers').

 --color <when> When to use colors (*auto*, never, always).
 --italic-text <when> Use italics in output (always, *never*)
 --decorations <when>
 When to show the decorations (*auto*, never, always).

 --paging <when>
 Specify when to use the pager, or use `-P` to disable (*auto*, never,
 always).
 -m, --map-syntax <glob:syntax>...
 Use the specified syntax for files matching the glob pattern
 ('*.cpp:C++').
 --theme <theme> Set the color theme for syntax highlighting.
 --list-themes Display all supported highlighting themes.
 --style <components>
 Comma-separated list of style elements to display (*auto*, full, plain,
 changes, header, grid, rule, numbers, snip).
 -r, --line-range <N:M>... Only print the lines from N to M.
 -L, --list-languages Display all supported languages.
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all
details.
54 changes: 54 additions & 0 deletions tests/syntax-tests/source/cmd-help/test.cmd-help
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
bat 0.20.0 (e735562-modified)
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
bat [OPTIONS] [FILE]...
bat <SUBCOMMAND>

OPTIONS:
-A, --show-all
Show non-printable characters (space, tab, newline, ..).

-p, --plain Show plain style (alias for '--style=plain').
-l, --language <language> Set the language for syntax highlighting.
-H, --highlight-line <N:M>... Highlight lines N through M.
--file-name <name>... Specify the name to display for a file.
-d, --diff
Only show lines that have been added/removed/modified.

--tabs <T> Set the tab width to T spaces.
--wrap <mode>
Specify the text-wrapping mode (*auto*, never, character).

-n, --number
Show line numbers (alias for '--style=numbers').

--color <when> When to use colors (*auto*, never, always).
--italic-text <when> Use italics in output (always, *never*)
--decorations <when>
When to show the decorations (*auto*, never, always).

--paging <when>
Specify when to use the pager, or use `-P` to disable (*auto*, never,
always).
-m, --map-syntax <glob:syntax>...
Use the specified syntax for files matching the glob pattern
('*.cpp:C++').
--theme <theme> Set the color theme for syntax highlighting.
--list-themes Display all supported highlighting themes.
--style <components>
Comma-separated list of style elements to display (*auto*, full, plain,
changes, header, grid, rule, numbers, snip).
-r, --line-range <N:M>... Only print the lines from N to M.
-L, --list-languages Display all supported languages.
-h, --help Print this help message.
-V, --version Show version information.

ARGS:
<FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all
details.