Skip to content

Commit 087507b

Browse files
committed
Add prompt text -p shorthand form
1 parent 1ec6dd0 commit 087507b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ static void usage(bool err)
828828
"Basic options:\n"
829829
" -h, --help Print this message and exit.\n"
830830
" -c, --config <path> Specify a config file.\n"
831-
" --prompt-text <string> Prompt text.\n"
831+
" -p, --prompt-text <string> Prompt text.\n"
832832
" --width <px|%> Width of the window.\n"
833833
" --height <px|%> Height of the window.\n"
834834
" --output <name> Name of output to display window on.\n"
@@ -867,7 +867,7 @@ const struct option long_options[] = {
867867
{"text-cursor-background", required_argument, NULL, 0},
868868
{"text-cursor-corner-radius", required_argument, NULL, 0},
869869
{"text-cursor-thickness", required_argument, NULL, 0},
870-
{"prompt-text", required_argument, NULL, 0},
870+
{"prompt-text", required_argument, NULL, 'p'},
871871
{"prompt-padding", required_argument, NULL, 0},
872872
{"prompt-color", required_argument, NULL, 0},
873873
{"prompt-background", required_argument, NULL, 0},
@@ -929,7 +929,7 @@ const struct option long_options[] = {
929929
{"late-keyboard-init", optional_argument, NULL, 'k'},
930930
{NULL, 0, NULL, 0}
931931
};
932-
const char *short_options = ":hc:";
932+
const char *short_options = ":hc:p:";
933933

934934
static void parse_args(struct tofi *tofi, int argc, char *argv[])
935935
{
@@ -940,7 +940,7 @@ static void parse_args(struct tofi *tofi, int argc, char *argv[])
940940
/* Handle errors ourselves. */
941941
opterr = 0;
942942

943-
/* First pass, just check for config file, help, and errors. */
943+
/* First pass, just check for config file, help, prompt and errors. */
944944
optind = 1;
945945
int opt = getopt_long(argc, argv, short_options, long_options, &option_index);
946946
while (opt != -1) {
@@ -950,6 +950,8 @@ static void parse_args(struct tofi *tofi, int argc, char *argv[])
950950
} else if (opt == 'c') {
951951
config_load(tofi, optarg);
952952
load_default_config = false;
953+
} else if (opt == 'p') {
954+
snprintf(tofi->window.entry.prompt_text, N_ELEM(tofi->window.entry.prompt_text), "%s", optarg);
953955
} else if (opt == ':') {
954956
log_error("Option %s requires an argument.\n", argv[optind - 1]);
955957
usage(true);

0 commit comments

Comments
 (0)