Repository navigation
Conversation
Passing - as the output path now writes the archive bytes to stdout instead of creating a file literally named -, matching the convention used by tar and by `ouch decompress`, which already reads stdin on -. Since stdout has no extension, --format is required to pick the format; without it a dedicated error suggests the flag instead of hinting at output names like "-.tar.gz". All diagnostics already go to stderr, so the piped stream stays clean. Conflict resolution, the output-size report, and partial-file cleanup are skipped for the stdout target. compress_files now takes a generic Write instead of fs::File to support this. Refs: ouch-org#1092
Collaborator
|
Author
|
Addressed in 6cbdf71. |
Collaborator
|
With output "-" a file that stdout is redirected to inside the compressed directory is not skipped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1092. Complements #110 (which covers
-= stdin for decompress; this is the compress-side twin).Bug
ouch compress <files> -created a literal file named-on disk (or, without--format, a confusing "Cannot compress to -" error hinting at-.tar.gz).Fix — stream to stdout,
--formatrequiredSince stdout has no extension to detect a format from,
-requires--format— mirroringouch decompress -, which already reads stdin on-and likewise requires--format(precedent also in #687).commands/mod.rs: onis_path_stdin(&output_path)the output writer isio::stdout(); conflict resolution, the size report, and partial-file cleanup are skipped for the stdout target.commands/compress.rs:compress_filestakesimpl Writeinstead offs::File(wrapped in the existing BufWriter).check.rs: dedicated error —Cannot compress to "-" (stdout)+--formathint — replaces the nonsense-.tar.gzsuggestion.args.rshelp documents-→ stdout;tests/integration.rsgains acompress_to_stdouttest (error without--format, tar stream, no literal-file, decompress roundtrip).Verified
ouch compress a.txt - --format tar | wc -c→ 2048;filesaysPOSIX tar archivecompress a.txt sub - --format tar > out.tar→tar tflists entries; INFO logs on stderrcompress … - --format tar.gz | decompress - --format tar.gz -d out→ files extractedzip/gzstream correctly; normalcompress f out.zipunchanged| head -c 100→ quiet truncation, exit 0cargo testall green (53 unit + 58 integration + ui/mime);fmt/clippy -D warningsclean (default +--no-default-features).Open to maintainer choice on whether bare
-could default to a format instead of requiring the flag — easy to relax.