diff options
author | Shav Kinderlehrer <[email protected]> | 2023-04-19 10:46:17 -0400 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2023-04-19 10:46:17 -0400 |
commit | 976bd09627375b7a4b524495e08ba15777ef788f (patch) | |
tree | af8bfbeda5730a3bba811d7670c5f733dd47a7a4 /src/lib | |
parent | e586f29e6d2974be68994405ff35684353883444 (diff) | |
download | lat-976bd09627375b7a4b524495e08ba15777ef788f.tar.gz lat-976bd09627375b7a4b524495e08ba15777ef788f.zip |
Add argsv0.10.0
- --pager
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/arg.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/arg.c b/src/lib/arg.c index e25b1db..1a5713d 100644 --- a/src/lib/arg.c +++ b/src/lib/arg.c @@ -18,23 +18,27 @@ void help(void) { "\t-t, --headers\t toggle whether to print file headers or not\n" "\t-b, --binary\t toggle whether to force the data to be treated as " "binary or not. see examples\n" + "\t-p, --pager\t print file a pager (less)\n" "\t-V, --version\t show program version\n" - "\t-h, --help\t display this help text\n\n"); + "\t-h, --help\t display this help text (--help shows additional info)\n\n"); printf("environment:\n" "\tNO_COLOR, see https://no-color.org/\n\n"); +} + +void examples(void) { printf( "examples:\n" "\tlat file1\n\t\t print the content of file1 witht default formatting\n" "\tlat - file1\n\t\t read from stdin (the '-' character reads from " "stdin) " "and then print the contents of stdin and file1\n" - "\tlat --lines --color file1 file2\n\t\t print the contents of file1 and " + "\tlat -nc file1 file2\n\t\t print the contents of file1 and " "file2 " "without printing line numbers or colors\n" "\tlat --binary file.txt\n\t\t force file.txt to be treated as a binary " "file\n" - "\tlat -bb file.txt\n\t\t force file.txt to NOT be treated as a binary " - "file\n" + "\tlat -bb --pager file.txt\n\t\t force file.txt to NOT be treated " + "as a binary file and print it in the pager\n" "\tcurl example.com | lat\n\t\t pipe the results of 'curl example.com' " "into lat\n"); } @@ -76,8 +80,13 @@ void parselongarg(char *arg) { return; } + if (strcmp(arg, "--pager") == 0) { + conf.pager = !conf.pager; + } + if (strcmp(arg, "--help") == 0) { help(); + examples(); exit(EXIT_SUCCESS); return; } @@ -111,6 +120,9 @@ void parseshortarg(char *arg) { else conf.force_binary = !conf.force_binary; break; + case 'p': + conf.pager = !conf.pager; + break; case 'V': version(); exit(EXIT_SUCCESS); |