- Usage - basic usage
- Algorithms - list of supported compression algorithms
- Platforms - list of supported platforms
- Releases - where to find an executable
- Examples - detailed usage exampels
- Building - how to build the CLI
- Testing - test the CLI
- Troubleshooting - how to troubleshoot common errors
The command line tool, grw, can be used to easily read and write compressed resources by uri. By default grw, reads from stdin and outputs to stdout. The --input-compression and --output-compression flags are optional.
grw [--input-compression INPUT_COMPRESSION] [--output-compression OUTPUT_COMPRESSION] [flags]To read from a resource provided by a URI use the first positional argument.
grw [--input-compression INPUT_COMPRESSION] [--output-compression OUTPUT_COMPRESSION] [flags] [-|stdin|INPUT_URI]To write to a resource located by a URI, use the second positional argument.
grw [--input-compression INPUT_COMPRESSION] [--output-compression OUTPUT_COMPRESSION] [flags] [-|stdin|INPUT_URI] [-|stdout|OUTPUT_URI]For more information use the help flag.
grw --helpThe following compression algorithms are supported. Pull requests to support other compression algorithms are welcome!
| Algorithm | Read | Write | Stream | Description |
|---|---|---|---|---|
| bzip2 | ✓ | - | ✓ | bzip2 |
| flate | ✓ | ✓ | ✓ | DEFLATE Compressed Data Format |
| gzip | ✓ | ✓ | ✓ | gzip |
| snappy | ✓ | ✓ | ✓ | snappy |
| zip | ✓ | - | - | zip |
| zlib | ✓ | ✓ | ✓ | zlib |
The following platforms are supported. Pull requests to support other platforms are welcome!
| GOOS | 386 | amd64 | arm | arm64 |
|---|---|---|---|---|
| darwin | - | ✓ | - | - |
| freebsd | ✓ | ✓ | ✓ | - |
| linux | ✓ | ✓ | ✓ | ✓ |
| openbsd | ✓ | ✓ | - | - |
| solaris | - | ✓ | - | - |
| windows | ✓ | ✓ | - | - |
Find releases for the supported platforms at https://github.com/spatialcurrent/go-reader-writer/releases. See the Building section below to build for another platform from source.
To download a file over https and write to stdout.
grw https://github.com/spatialcurrent/go-reader-writer/releases/download/0.0.1/grw.h -To download a file from AWS S3, compress as gzip, and save locally.
grw --output-compression gzip s3://path/to/file /local/fileUse make build_cli to build executables for Linux and Windows.
Changing Destination
The default destination for build artifacts is grw/bin, but you can change the destination with an environment variable. For building on a Chromebook consider saving the artifacts in /usr/local/go/bin, e.g., DEST=/usr/local/go/bin make build_cli
To run CLI testes use make test_cli, which uses shUnit2. If you recive a shunit2:FATAL Please declare TMPDIR with path on partition with exec permission. error, you can modify the TMPDIR environment variable in line or with export TMPDIR=<YOUR TEMP DIRECTORY HERE>. For example:
TMPDIR="/usr/local/tmp" make test_cli
error opening resource at uri %q: error opening file for writing at path %q: open %s: no such file or directory
This error typically occurs when a parent directory of an output file does not exist. Use the --output-mkdirs command line flag to allow grw to create parent directories for output files as needed.