cli: add --output alias for -o

This commit is contained in:
mukunda katta 2026-05-14 19:28:33 -07:00
parent 885c79ba4a
commit b0aebdfece
2 changed files with 15 additions and 1 deletions

View file

@ -148,7 +148,7 @@ static void usage(FILE* f, const char* programName)
DISPLAY_F(f, "Compress or decompress the INPUT file(s); reads from STDIN if INPUT is `-` or not provided.\n\n");
DISPLAY_F(f, "Usage: %s [OPTIONS...] [INPUT... | -] [-o OUTPUT]\n\n", programName);
DISPLAY_F(f, "Options:\n");
DISPLAY_F(f, " -o OUTPUT Write output to a single file, OUTPUT.\n");
DISPLAY_F(f, " -o, --output OUTPUT Write output to a single file, OUTPUT.\n");
DISPLAY_F(f, " -c, --stdout Write to STDOUT (even if it is a console) and keep the INPUT file(s).\n");
DISPLAY_F(f, " -k, --keep Preserve INPUT file(s). [Default] \n");
DISPLAY_F(f, " --rm Remove INPUT file(s) after successful (de)compression to file.\n");
@ -1139,6 +1139,7 @@ int main(int argCount, const char* argv[])
continue;
}
#endif
if (longCommandWArg(&argument, "--output")) { NEXT_FIELD(outFileName); continue; }
#ifndef ZSTD_NOTRACE
if (longCommandWArg(&argument, "--trace")) { char const* traceFile; NEXT_FIELD(traceFile); TRACE_enable(traceFile); continue; }
#endif

13
tests/cli-tests/basic/output.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
echo "some data" > file
println "+ zstd -q file --output compressed.zst"
zstd -q file --output compressed.zst
test -f compressed.zst || die "Expected --output to create compressed.zst"
println "+ zstd -q -d compressed.zst --output roundtrip"
zstd -q -d compressed.zst --output roundtrip
cmp file roundtrip || die "Expected --output decompression to round-trip"
exit 0