this repo has no description
1# cmprss
2
3[](https://github.com/arcuru/cmprss/actions?query=workflow%3ANix)
4[](https://crates.io/crates/cmprss)
5[](https://codecov.io/gh/arcuru/cmprss)
6
7
8**Mirrored on [GitHub](https://github.com/arcuru/cmprss) and [Codeberg](https://codeberg.org/arcuru/cmprss). GitHub is the official repo, but use either repo to contribute. Issues can't be synced so there may be some duplicates.**
9
10A compression multi-tool for the command line.
11Replace `tar` with something you can remember.
12[Relevant XKCD](https://xkcd.com/1168/).
13
14All compression libraries are statically compiled in, so no runtime dependencies required.
15
16Currently supports:
17
18- bzip2
19- gzip
20- lz4
21- tar
22- xz
23- zip
24- zstd
25
26## Install
27
28Installation is available through source code and cargo. `cargo install cmprss` will install the latest version.
29
30For Nix users, the repository contains a flake and an overlay. `nix run github:arcuru/cmprss`
31
32A fully static musl-linked binary is also available for Linux: `nix build github:arcuru/cmprss#cmprss-static`
33
34## Usage
35
36The primary goal is to infer behavior based on the input, so that you don't need to remember esoteric CLI arguments.
37
38`cmprss` supports being very explicit about the inputs and outputs for scripting, but will also behave intelligently when you leave out info.
39
40All commands read from left to right, input is always either piped from `stdin` or the first filename(s) specified, and output is either `stdout` or the last filename/directory.
41
42The easiest way to understand is to look at some examples
43
44Compress a file with gzip
45
46```bash
47cmprss file.txt file.txt.gz
48```
49
50Compress 2 files into a tar archive
51
52```bash
53cmprss file1.txt file2.txt archive.tar
54```
55
56Compress stdin with xz
57
58```bash
59cat file.txt | cmprss file.xz
60```
61
62Extract a tar archive to the current directory
63
64```bash
65cmprss archive.tar
66```
67
68Extract an xz compressed file
69
70```bash
71cmprss file.xz file.txt
72```
73
74Extract a gzip compressed file to stdout
75
76```bash
77cmprss file.txt.gz > file.txt
78```
79
80### Multi-level Compression
81
82`cmprss` supports multi-level archives like `.tar.gz`, `.tar.xz`, or `.zstd.bz2` directly:
83
84```bash
85# Compress a directory to a tar.gz file
86cmprss directory out.tar.gz
87
88# Extract a tar.xz file to a directory
89cmprss --extract archive.tar.xz output_dir
90
91# Gzip an existing tar archive
92cmprss archive.tar archive.tar.gz
93
94# Extract just the xz layer
95cmprss archive.tar.xz archive.tar
96```
97
98Pipes can still be used if preferred:
99
100```bash
101cmprss tar dir | cmprss gz | cmprss gz -e | cmprss tar -e
102```
103
104### Examples of Explicit Behavior
105
106All these examples will work with _any_ of the supported compression formats, provided that they support the input/output formats.
107
108If output filenames are left out, `cmprss` will try to infer the filename based on the compression type.
109
110Compress a file/directory to a `tar` archive:
111
112```bash
113cmprss tar filename # outputs to filename.tar
114cmprss tar filename my_preferred_output_name.tar
115```
116
117Compress 2 files/directories into a `tar` archive:
118
119```bash
120cmprss tar dir_1/ dir_2/ combined.tar
121cmprss tar file_1.txt file_2.txt # outputs to file_1.txt.tar
122```
123
124Extract a `tar` archive:
125
126```bash
127cmprss tar --extract archive.tar # extracts to the current directory
128cmprss tar -e archive.tar custom_output_directory
129```
130
131`cmprss` will detect if `stdin` or `stdout` is a pipe, and use those for I/O where it makes sense.
132
133Create and extract a `tar.gz` archive with pipes:
134
135```bash
136cmprss tar directory | cmprss gzip > directory.tar.gz
137cmprss gzip --extract directory.tar.gz | cmprss tar -e new_directory
138
139# Or a full roundtrip in one line
140cmprss tar directory_1/ directory_2/ | cmprss gzip | cmprss gzip -e | cmprss tar -e new_directory
141```
142
143## Contributing
144
145### Development Environment
146
147The primary supported developer environment is defined in the `flake.nix` file.
148This is a [Nix Flake](https://nixos.wiki/wiki/Flakes) that pins versions of all packages used by `cmprss`.
149It includes a `devShell` that can be used with [direnv](https://direnv.net/) to use the tools each time you enter the directory.
150
151That being said, `cmprss` is a very standard Rust application and should work with recent Rust toolchains.
152
153The CI runs on both a stable Rust toolchain and the pinned Nix versions to verify correctness of both.
154
155If you run into any issues developing with either the Nix environment or a stable Rust environment, please open a Github issue with the details.
156
157### Conventional Commits
158
159Commits should conform to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
160
161A script to help create conforming commits is provided in `bin/commit.sh`, or via `task commit`.
162
163### Test Coverage
164
165PRs that improve the test coverage are encouraged.
166
167Test coverage can be measured using `cargo llvm-cov report` and `cargo tarpaulin`.