From f839282ac0b9f6a071dd896886900c43c705b6f3 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sun, 3 Jul 2016 05:02:32 -0700 Subject: [PATCH] fish_key_reader had no -h output --- doc_src/fish_key_reader.txt | 12 +++++++----- src/fish_key_reader.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc_src/fish_key_reader.txt b/doc_src/fish_key_reader.txt index 73156d0a3..6c7270d69 100644 --- a/doc_src/fish_key_reader.txt +++ b/doc_src/fish_key_reader.txt @@ -2,22 +2,24 @@ \subsection fish_key_reader-synopsis Synopsis \fish{synopsis} -fish_key_reader [-c] [-d LEVEL] +fish_key_reader [-c] [-d LEVEL] | [-h] \endfish \subsection fish_key_reader-description Description -`fish_key_reader` is used to study input `fish` receives 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 a character sequence is read that matches a key name recognized by the `bind` command (see `bind --key-names`), additionally a bind command will also be shown for `bind -k` usage. +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 following parameters 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. -- `-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. -If using `-c`, the delay in milliseconds since the previous character was received is also shown. This timing data 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. + +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`. `fish_key_reader` intentionally disables handling of many signals. To terminate `fish_key_reader` in a `--continuous` run: - press `Ctrl-C` twice, or diff --git a/src/fish_key_reader.cpp b/src/fish_key_reader.cpp index ee4d80da2..d36865ef7 100644 --- a/src/fish_key_reader.cpp +++ b/src/fish_key_reader.cpp @@ -24,6 +24,7 @@ #include "input.h" #include "input_common.h" #include "proc.h" +#include "print_help.h" #include "reader.h" #include "signal.h" #include "wutil.h" // IWYU pragma: keep @@ -289,10 +290,11 @@ static void setup_and_process_keys(bool continuous_mode) { int main(int argc, char **argv) { program_name = L"fish_key_reader"; bool continuous_mode = false; - const char *short_opts = "+cd:D:"; + const char *short_opts = "+cd:D:h"; const struct option long_opts[] = {{"continuous", no_argument, NULL, 'c'}, {"debug-level", required_argument, NULL, 'd'}, {"debug-stack-frames", required_argument, NULL, 'D'}, + {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}}; int opt; while ((opt = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { @@ -305,6 +307,10 @@ int main(int argc, char **argv) { continuous_mode = true; break; } + case 'h': { + print_help("fish_key_reader", 0); + exit(0); + } case 'd': { char *end; long tmp;