Fix --help grammar

This commit is contained in:
Shav Kinderlehrer 2023-04-19 12:43:54 -04:00
parent 23ede20d7c
commit 219075499f
3 changed files with 19 additions and 12 deletions

View File

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

View File

@ -13,14 +13,15 @@ void help(void) {
printf("%s\n\n", LAT_USAGE); 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 color\n"
"\t-n, --lines\t toggle whether to print line numbers or not\n" "\t-n, --lines\t toggle line numbers\n"
"\t-t, --headers\t toggle whether to print file headers or not\n" "\t-t, --headers\t toggle file info headers\n"
"\t-b, --binary\t toggle whether to force the data to be treated as " "\t-b, --binary\t toggle binary mode, -b forces binary and -bb forces "
"binary or not. see examples\n" "NOT binary\n"
"\t-p, --pager\t print file a pager (less)\n" "\t-p, --pager\t print file with the pager (uses less)\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 (--help shows additional info)\n\n"); "\t-h, --help\t display this help text (--help shows additional "
"info)\n\n");
printf("environment:\n" printf("environment:\n"
"\tNO_COLOR, see https://no-color.org/\n\n"); "\tNO_COLOR, see https://no-color.org/\n\n");
} }
@ -28,8 +29,9 @@ void help(void) {
void examples(void) { void examples(void) {
printf( printf(
"examples:\n" "examples:\n"
"\tlat file1\n\t\t print the content of file1 witht default formatting\n" "\tlat file1\n\t\t print the contents of file1 with the default "
"\tlat - file1\n\t\t read from stdin (the '-' character reads from " "formatting\n"
"\tlat - file1\n\t\t read from stdin (the '-' flag reads from "
"stdin) " "stdin) "
"and then print the contents of stdin and file1\n" "and then print the contents of stdin and file1\n"
"\tlat -nc file1 file2\n\t\t print the contents of file1 and " "\tlat -nc file1 file2\n\t\t print the contents of file1 and "

View File

@ -42,8 +42,11 @@ void run(FILE *fp, char *filename, bool tty) {
if (conf.headers) { if (conf.headers) {
char *addon = f.binary ? "<binary>" : ""; char *addon = f.binary ? "<binary>" : "";
if (!conf.pager)
fprintf(err, "\x1b[2K\r%s%s%s%s\r\n", invert_t, basename(filename), addon, fprintf(err, "\x1b[2K\r%s%s%s%s\r\n", invert_t, basename(filename), addon,
reset); reset);
else
fprintf(err, "%s%s%s%s\r\n", invert_t, basename(filename), addon, reset);
} }
conf.process = (tty && !f.binary); conf.process = (tty && !f.binary);
@ -68,11 +71,13 @@ void run(FILE *fp, char *filename, bool tty) {
} }
} else { } else {
fwrite(f.buf, 1, f.buflen, st); fwrite(f.buf, 1, f.buflen, st);
fflush(st);
fwrite("\n", 1, 1, err); fwrite("\n", 1, 1, err);
} }
free(f.buf); free(f.buf);
fflush(st); // prevent timing inconsistencies between st and err fflush(st); // prevent timing inconsistencies between st and err
fflush(err);
if (conf.headers) { if (conf.headers) {
float rounded; float rounded;