diff options
author | Shav Kinderlehrer <[email protected]> | 2023-04-17 21:07:24 -0400 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2023-04-17 21:13:20 -0400 |
commit | 2abab7c9e85ccda8abf12f0bdf70f2a6a1c1ffa0 (patch) | |
tree | 11eaa6d8c5a69b4844f0b1bd70ec2859e5b0a398 /src/lib/arg.c | |
parent | f853dabe7f3585ec856669c6711df08087b65cd8 (diff) | |
download | lat-2abab7c9e85ccda8abf12f0bdf70f2a6a1c1ffa0.tar.gz lat-2abab7c9e85ccda8abf12f0bdf70f2a6a1c1ffa0.zip |
Add argsv0.8.0
- --binary
Diffstat (limited to 'src/lib/arg.c')
-rw-r--r-- | src/lib/arg.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/lib/arg.c b/src/lib/arg.c index 104b836..95badbb 100644 --- a/src/lib/arg.c +++ b/src/lib/arg.c @@ -4,15 +4,18 @@ #include <stdlib.h> #include <string.h> -#define LAT_USAGE "usage: lat [-cnVh] [files..]" +#define LAT_USAGE "usage: lat [-cnbVh] [files..]" void help(void) { printf("%s\n", LAT_USAGE); printf("options:\n" "\t-c, --color\t toggle whether to print color or not\n" "\t-n, --lines\t toggle whether to print line numbers or not\n" + "\t-b, --binary\t toggle whether to force the data to be treated as " + "binary or not\n" "\t-V, --version\t show program version\n" "\t-h, --help\t display this help text\n"); + printf(""); } void version(void) { @@ -37,6 +40,11 @@ void parselongarg(char *arg) { return; } + if (strcmp(arg, "--binary") == 0) { + conf.force_binary = !conf.force_binary; + return; + } + if (strcmp(arg, "--help") == 0) { help(); exit(EXIT_SUCCESS); @@ -63,14 +71,17 @@ void parseshortarg(char *arg) { case 'n': conf.lines = !conf.lines; break; - case 'h': - help(); - exit(EXIT_SUCCESS); + case 'b': + conf.force_binary = !conf.force_binary; break; case 'V': version(); exit(EXIT_SUCCESS); break; + case 'h': + help(); + exit(EXIT_SUCCESS); + break; default: { char *str = malloc(2); str[0] = c; |