From c43e1611437bcb450526f5624712dcde8d061245 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 21 Nov 2022 12:50:42 +0000 Subject: Remove most options from usage info. The list was getting far too long, and is about to get even longer with text styling options. The user is instead directed to the manpage. Also, don't print usage to stderr if `-h` was passed. --- src/main.c | 72 ++++++++------------------------------------------------------ 1 file changed, 9 insertions(+), 63 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 1feefda..500edfb 100644 --- a/src/main.c +++ b/src/main.c @@ -752,77 +752,23 @@ static const struct wl_surface_listener dummy_surface_listener = { }; -static void usage() +static void usage(bool err) { - /* - * This string literal is more than 4095 characters, which is the - * maximum size guaranteed to work in C, so we have to split it. - */ - fprintf(stderr, "%s", + fprintf(err ? stderr : stdout, "%s", "Usage: tofi [options]\n" "\n" +"Basic options:\n" " -h, --help Print this message and exit.\n" " -c, --config Specify a config file.\n" -" --include Include an additional config file.\n" -" --font Font to use.\n" -" --font-size Point size of text.\n" -" --font-features Set OpenType font features.\n" -" --font-variations Set OpenType font variations.\n" -" --background-color Color of the background.\n" -" --outline-width Width of the border outlines.\n" -" --outline-color Color of the border outlines.\n" -" --border-width Width of the border.\n" -" --border-color Color of the border.\n" -" --text-color Color of text.\n" " --prompt-text Prompt text.\n" -" --prompt-padding Padding between prompt and input.\n" -" --placeholder-text Placeholder input text.\n" -" --placeholder-color Color of placeholder input text.\n" -" --num-results Maximum number of results to display.\n" -" --selection-color Color of selected result.\n" -" --selection-match-color Color of the matching portion of the\n" -" selected result.\n" -" --selection-padding Extra horizontal padding for selected\n" -" result background.\n" -" --selection-background Color of selected result background.\n" -" --result-spacing Spacing between results.\n" -" --min-input-width Minimum input width in horizontal mode.\n" " --width Width of the window.\n" - ); - fprintf(stderr, "%s", " --height Height of the window.\n" -" --corner-radius Radius of window corners.\n" " --output Name of output to display window on.\n" -" --scale Follow the output's scale factor.\n" " --anchor Location on screen to anchor window.\n" -" --exclusive-zone <-1|px|%> Exclusive zone size, or -1 for none.\n" -" --margin-top Offset from top of screen.\n" -" --margin-bottom Offset from bottom of screen.\n" -" --margin-left Offset from left of screen.\n" -" --margin-right Offset from right of screen.\n" -" --padding-top Padding between top border and text.\n" -" --padding-bottom Padding between bottom border and text.\n" -" --padding-left Padding between left border and text.\n" -" --padding-right Padding between right border and text.\n" -" --hide-cursor Hide the cursor.\n" " --horizontal List results horizontally.\n" -" --history Sort results by number of usages.\n" -" --history-file Location of history file.\n" " --fuzzy-match Use fuzzy matching for searching.\n" -" --require-match Require a match for selection.\n" -" --hide-input Hide sensitive input such as passwords.\n" -" --hidden-character Replacement character for hidden input.\n" -" --drun-launch Launch apps directly in drun mode.\n" -" --drun-print-exec Print a command line in drun mode.\n" -" This is now always the case,\n" -" and this option is deprecated.\n" -" --terminal Terminal to use for command line\n" -" programs in drun mode.\n" -" --hint-font Perform font hinting.\n" -" --multi-instance Allow multiple tofi instances at once.\n" -" --late-keyboard-init (EXPERIMENTAL) Delay keyboard\n" -" initialisation until after the first\n" -" draw to screen.\n" +"\n" +"All options listed in \"man 5 tofi\" are also accpted in the form \"--key=value\".\n" ); } @@ -899,14 +845,14 @@ static void parse_args(struct tofi *tofi, int argc, char *argv[]) int opt = getopt_long(argc, argv, short_options, long_options, &option_index); while (opt != -1) { if (opt == 'h') { - usage(); + usage(false); exit(EXIT_SUCCESS); } else if (opt == 'c') { config_load(tofi, optarg); load_default_config = false; } else if (opt == ':') { log_error("Option %s requires an argument.\n", argv[optind - 1]); - usage(); + usage(true); exit(EXIT_FAILURE); } else if (opt == '?') { if (optopt) { @@ -914,7 +860,7 @@ static void parse_args(struct tofi *tofi, int argc, char *argv[]) } else { log_error("Unknown option %s.\n", argv[optind - 1]); } - usage(); + usage(true); exit(EXIT_FAILURE); } opt = getopt_long(argc, argv, short_options, long_options, &option_index); @@ -945,7 +891,7 @@ static void parse_args(struct tofi *tofi, int argc, char *argv[]) if (optind < argc) { log_error("Unexpected non-option argument '%s'.\n", argv[optind]); - usage(); + usage(true); exit(EXIT_FAILURE); } } -- cgit v1.2.3