google / google/brotli

print help to stdout, help screen, man

Open
#1,164 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14.9k
Forks
1.4k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

print help to stdout, help screen, man

As you require signing CLA for technically trivial though important things I post it in an issue.

According to GNU coding standards `--help' should be printed to stdout. It makes sense as long help screen can be paged (`$ prog --help | more`), searched and so on.
There is an issue with the paging here because when paged with less(1) it makes black screen and even leaving it is difficult. I understand that is the issue but I made it to acknowledge the problem.

~~~
diff --git a/c/tools/brotli.c b/c/tools/brotli.c
index 0dc99bd3..9a1a3c66 100644
--- a/c/tools/brotli.c
+++ b/c/tools/brotli.c
@@ -1543,7 +1543,7 @@ int main(int argc, char** argv) {
case COMMAND_INVALID:
default:
is_ok = (command == COMMAND_HELP);
- PrintHelp(FileName(argv[0]), is_ok);
+ PrintHelp(FileName(argv[0]), !is_ok);
break;
}

~~~

Do not separate --keep and --rm options on help screen - move --squash below.

~~~
diff --git a/c/tools/brotli.c b/c/tools/brotli.c
index 0dc99bd3..7963f370 100644
--- a/c/tools/brotli.c
+++ b/c/tools/brotli.c
@@ -731,8 +731,8 @@ static void PrintHelp(const char* name, BROTLI_BOOL error) {
" -h, --help display this help and exit\n");
fprintf(media,
" -j, --rm remove source file(s)\n"
-" -s, --squash remove destination file if larger than source\n"
" -k, --keep keep source file(s) (default)\n"
+" -s, --squash remove destination file if larger than source\n"
" -n, --no-copy-stat do not copy source file(s) attributes\n"
" -o FILE, --output=FILE output file (only if 1 input file)\n");
fprintf(media,
~~~

Modified manual for v1.1.0 to include new option/s.

~~~
diff --git a/docs/brotli.1 b/docs/brotli.1
index 14a4de1f..d0076c8b 100644
--- a/docs/brotli.1
+++ b/docs/brotli.1
@@ -1,6 +1,7 @@
.\" Automatically generated by Pandoc 2.7.3
+.\" Manually corrected
.\"
-.TH "brotli" "1" "August 14 2021" "brotli 1.0.9" "User Manual"
+.TH "brotli" "1" "August 29 2023" "brotli 1.1.0" "User Manual"
.hy
.SH NAME
.PP
@@ -89,6 +90,8 @@ slower compression
\f[B]-k\f[R], \f[B]--keep\f[R]: keep source file(s); \f[B]zstd
(1)\f[R]-like behaviour
.IP \[bu] 2
+\f[B]-s\f[R], \f[B]--squash\f[R]: remove destination file if larger than source
+.IP \[bu] 2
\f[B]-n\f[R], \f[B]--no-copy-stat\f[R]: do not copy source file(s)
attributes
.IP \[bu] 2
@@ -107,6 +110,11 @@ bigger values cause denser, but slower compression
compressor decide over the optimal value; bigger windows size improve
density; decoder might require up to window size memory to operate
.IP \[bu] 2
+\f[B]--large_window=NUM\f[R]: use incompatible large-window brotli
+bitstream with window size (0, 10-30) WARNING: this format is not
+compatible with brotli RFC 7932 and may not be decodable with regular
+brotli decoders
+.IP \[bu] 2
\f[B]-C B64\f[R], \f[B]--comment=B64\f[R]: set comment; argument is
base64-decoded first; when decoding: check stream comment; when
encoding: embed comment (fingerprint)
~~~

Contributor guide

Open the contributing guide

Research direction

Start in c/tools/brotli.c at main and PrintHelp, then compare the help output with docs/brotli.1. Done means --help is written to stdout, the --keep and --squash entries are ordered as requested, and the manual includes the v1.1.0 options shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli, documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.