diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-11-01 21:43:01 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-11-01 21:43:01 +0100 |
commit | 4f41e06880f4d9b979ec001da5046373cd867c2f (patch) | |
tree | f084ed93e8387e3fa814aa17dee80b5a263bf81b /src/main.c | |
parent | 420d354fffa1e69f050ba32d8521c6d84c4f8dd1 (diff) |
Add -H
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -69,6 +69,7 @@ main(int argc, char **argv) {'b', U8C("byte-offset"), CLI_NONE}, {'c', U8C("color"), CLI_NONE}, {'h', U8C("help"), CLI_NONE}, + {'H', U8C("header-line"), CLI_REQ}, {'i', U8C("ignore-case"), CLI_NONE}, {'l', U8C("literal"), CLI_NONE}, {'L', U8C("line-position"), CLI_NONE}, @@ -95,6 +96,26 @@ main(int argc, char **argv) case 'h': execlp("man", "man", "1", mlib_progname(), nullptr); err("execlp: man 1 %s:", mlib_progname()); + case 'H': + if (ucseq(parser.optarg, U8("never"))) + flags.H = HDR_NEVER; + else if (ucseq(parser.optarg, U8("multi"))) + flags.H = HDR_MULTI; + else if (ucseq(parser.optarg, U8("always"))) + flags.H = HDR_ALWAYS; + else if (parser.optarg.len == 0) { + warn("empty value given for option %s--header-line%s", + lquot, rquot); + goto usage; + } else { + warn("unknown value %s%.*s%s for option %s--header-line%s", + lquot, SV_PRI_ARGS(parser.optarg), rquot, lquot, rquot); + goto usage; + } +#if !GIT_GRAB + flags.do_header = true; +#endif + break; case 'i': flags.i = true; break; @@ -130,7 +151,7 @@ main(int argc, char **argv) if (argc == 0) { usage: - usage("[-bcilLpsUz] pattern [file ...]", "-h"); + usage("[-H never|multi|always] [-bcilLpsUz] pattern [file ...]", "-h"); exit(EXIT_FATAL); } |