From 0e1183a62cb98f52393961f7d40524f3754ec22e Mon Sep 17 00:00:00 2001 From: Shav Kinderlehrer Date: Mon, 17 Apr 2023 23:58:23 -0400 Subject: [PATCH] Update help message - add usage - add env - add description --- include/arg.h | 2 +- src/lib/arg.c | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/arg.h b/include/arg.h index cd0a77a..138a44b 100644 --- a/include/arg.h +++ b/include/arg.h @@ -2,7 +2,7 @@ #define ARG_H #include -#define LAT_VERSION "0.9.1" +#define LAT_VERSION "0.9.2" struct config { bool stdin; diff --git a/src/lib/arg.c b/src/lib/arg.c index 5437f99..6f4d714 100644 --- a/src/lib/arg.c +++ b/src/lib/arg.c @@ -5,10 +5,13 @@ #include "arg.h" #include "util.h" -#define LAT_USAGE "usage: lat [-cnbVh] [files..]" +#define LAT_USAGE "usage: lat [-cntbVh] [file...]" void help(void) { - printf("%s\n", LAT_USAGE); + printf("lat | lazy cat - a cat clone with some quality-of-life " + "embelishments\n\n"); + + printf("%s\n\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" @@ -16,8 +19,17 @@ void help(void) { "\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(""); + "\t-h, --help\t display this help text\n\n"); + printf("environment:\n" + "\tNO_COLOR, see https://no-color.org/\n\n"); + 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 -nc file1 file2\n\t\t print the contents of file1 and file2 " + "without printing line numbers or colors\n" + "\tcurl example.com | lat\n\t\t pipe the results of 'curl example.com' " + "into lat\n"); } void version(void) { @@ -26,8 +38,10 @@ void version(void) { struct config conf; void argerr(char *r, char *arg) { - printf("lat: %s '%s'\n", r, arg); + printf("lat: %s '%s'\n\n", r, arg); + printf("%s\n", LAT_USAGE); + printf("run '--help' for more information\n"); exit(EXIT_FAILURE); }