make fish_indent options consistent with fish

Make `fish_indent`, `fish_key_reader` and `fish` recognize and assign
the same meaning to the `-d` and `-D` flags. Also, fix some errors and
stylistic issues in the associated man pages.

Fixes #3191
This commit is contained in:
Kurtis Rader 2016-07-05 20:22:44 -07:00
parent 755d0089f3
commit 3c4e322ec1
3 changed files with 66 additions and 22 deletions

View file

@ -11,14 +11,18 @@ fish_indent [OPTIONS]
The following options are available: The following options are available:
- `-d` or `--dump` dumps information about the parsed fish commands to stderr - `-w` or `--write` indents a specified file and immediately writes to that file.
- `-w` or `--write` indents a specified file and immediately writes to that file - `-i` or `--no-indent` do not indent commands; only reformat to one job per line.
- `-i` or `--no-indent` do not indent commands; only reformat to one job per line - `-v` or `--version` displays the current fish version and then exits.
- `-v` or `--version` displays the current fish version and then exits
- `--ansi` colorizes the output using ANSI escape sequences, appropriate for the current $TERM, using the colors defined in the environment (such as `$fish_color_command`). - `--ansi` colorizes the output using ANSI escape sequences, appropriate for the current $TERM, using the colors defined in the environment (such as `$fish_color_command`).
- `--html` outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as `fish_color_command` - `--html` outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as `fish_color_command`.
- `-d` or `--debug-level=DEBUG_LEVEL` enables debug output and specifies a verbosity level (like `fish -d`). Defaults to 0.
- `-D` or `--debug-stack-frames=DEBUG_LEVEL` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
- `--dump-parse-tree` dumps information about the parsed statements to stderr. This is likely to be of interest only to people working on the fish source code.

View file

@ -2,26 +2,31 @@
\subsection fish_key_reader-synopsis Synopsis \subsection fish_key_reader-synopsis Synopsis
\fish{synopsis} \fish{synopsis}
fish_key_reader [-c] [-d LEVEL] | [-h] fish_key_reader [OPTIONS]
\endfish \endfish
\subsection fish_key_reader-description Description \subsection fish_key_reader-description Description
`fish_key_reader` is used to study input received from the terminal and can help with key binds. The program is interactive and works on standard input. Individual characters themselves and their hexadecimal values are displayed. `fish_key_reader` is used to study input received from the terminal and can help with key binds. The program is interactive and works on standard input. Individual characters themselves and their hexadecimal values are displayed.
The tool will output an example `bind` command matching the character sequence captured. If the character sequence matches a special key name (see `bind --key-names`), both `bind CHARS ...` and `bind -k KEYNAME ...` usage will be shown. The tool will write an example `bind` command matching the character sequence captured to stdout. If the character sequence matches a special key name (see `bind --key-names`), both `bind CHARS ...` and `bind -k KEYNAME ...` usage will be shown. Additional details about the characters received, such as the delay between chars, are written to stderr.
The following parameters are available: The following options are available:
- `-c` or `--continuous` begins a session where multiple key sequences can be inspected. By default the program exits after capturing a single key sequence. - `-c` or `--continuous` begins a session where multiple key sequences can be inspected. By default the program exits after capturing a single key sequence.
- `-d` or `--debug-level=DEBUG_LEVEL` enables debug output and specifies a verbosity level (like `fish -d`). Defaults to 0. - `-d` or `--debug-level=DEBUG_LEVEL` enables debug output and specifies a verbosity level (like `fish -d`). Defaults to 0.
- '-h' or '--help' prints usage information. - `-D` or `--debug-stack-frames=DEBUG_LEVEL` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
In continuous mode (`-c`), the delay in milliseconds since the previous character was received is also shown. This information may be useful to determine a preferred `fish_escape_delay_ms` setting or learn the amount of lag introduced by `ssh` or `tmux`. - `-h` or `--help` prints usage information.
\subsection fish_key_reader-usage-notes Usage Notes
The delay in milliseconds since the previous character was received is included in the diagnostic information written to stderr. This information may be useful to determine the optimal `fish_escape_delay_ms` setting or learn the amount of lag introduced by tools like `ssh`, `mosh` or `tmux`.
`fish_key_reader` intentionally disables handling of many signals. To terminate `fish_key_reader` in `--continuous` mode do:
`fish_key_reader` intentionally disables handling of many signals. To terminate `fish_key_reader` in a `--continuous` run:
- press `Ctrl-C` twice, or - press `Ctrl-C` twice, or
- press `Ctrl-D` twice, or - press `Ctrl-D` twice, or
- type `exit`, or - type `exit`, or

View file

@ -350,12 +350,17 @@ int main(int argc, char *argv[]) {
const char *output_location = ""; const char *output_location = "";
bool do_indent = true; bool do_indent = true;
const char *short_opts = "+dhvwi"; const char *short_opts = "+d:hvwiD:";
const struct option long_opts[] = { const struct option long_opts[] = {{"debug-level", required_argument, NULL, 'd'},
{"dump", no_argument, NULL, 'd'}, {"no-indent", no_argument, NULL, 'i'}, {"debug-stack-frames", required_argument, NULL, 'D'},
{"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"dump-parse-tree", no_argument, NULL, 'P'},
{"write", no_argument, NULL, 'w'}, {"html", no_argument, NULL, 1}, {"no-indent", no_argument, NULL, 'i'},
{"ansi", no_argument, NULL, 2}, {NULL, 0, NULL, 0}}; {"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"write", no_argument, NULL, 'w'},
{"html", no_argument, NULL, 1},
{"ansi", no_argument, NULL, 2},
{NULL, 0, NULL, 0}};
int opt; int opt;
while ((opt = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { while ((opt = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
@ -365,7 +370,7 @@ int main(int argc, char *argv[]) {
exit(127); exit(127);
break; break;
} }
case 'd': { case 'P': {
dump_parse_tree = true; dump_parse_tree = true;
break; break;
} }
@ -395,6 +400,36 @@ int main(int argc, char *argv[]) {
output_type = output_type_ansi; output_type = output_type_ansi;
break; break;
} }
case 'd': {
char *end;
long tmp;
errno = 0;
tmp = strtol(optarg, &end, 10);
if (tmp >= 0 && tmp <= 10 && !*end && !errno) {
debug_level = (int)tmp;
} else {
fwprintf(stderr, _(L"Invalid value '%s' for debug-level flag"), optarg);
exit(1);
}
break;
}
case 'D': {
char *end;
long tmp;
errno = 0;
tmp = strtol(optarg, &end, 10);
if (tmp > 0 && tmp <= 128 && !*end && !errno) {
debug_stack_frames = (int)tmp;
} else {
fwprintf(stderr, _(L"Invalid value '%s' for debug-stack-frames flag"), optarg);
exit(1);
}
break;
}
default: { default: {
// We assume getopt_long() has already emitted a diagnostic msg. // We assume getopt_long() has already emitted a diagnostic msg.
exit(1); exit(1);