Update help message

- add usage
- add env
- add description
This commit is contained in:
Shav Kinderlehrer 2023-04-17 23:58:23 -04:00
parent 0247ecc2a1
commit 0e1183a62c
2 changed files with 20 additions and 6 deletions

View File

@ -2,7 +2,7 @@
#define ARG_H #define ARG_H
#include <stdbool.h> #include <stdbool.h>
#define LAT_VERSION "0.9.1" #define LAT_VERSION "0.9.2"
struct config { struct config {
bool stdin; bool stdin;

View File

@ -5,10 +5,13 @@
#include "arg.h" #include "arg.h"
#include "util.h" #include "util.h"
#define LAT_USAGE "usage: lat [-cnbVh] [files..]" #define LAT_USAGE "usage: lat [-cntbVh] [file...]"
void help(void) { 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" printf("options:\n"
"\t-c, --color\t toggle whether to print color or not\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-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 " "\t-b, --binary\t toggle whether to force the data to be treated as "
"binary or not\n" "binary or not\n"
"\t-V, --version\t show program version\n" "\t-V, --version\t show program version\n"
"\t-h, --help\t display this help text\n"); "\t-h, --help\t display this help text\n\n");
printf(""); 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) { void version(void) {
@ -26,8 +38,10 @@ void version(void) {
struct config conf; struct config conf;
void argerr(char *r, char *arg) { 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("%s\n", LAT_USAGE);
printf("run '--help' for more information\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }