| CARVIEW |
hash-addressed-cli: Hash-addressed file storage app
A command-line interface for maintaining a directory wherein each file's name is a hash of its content.
[Skip to Readme]
Modules
[Index] [Quick Jump]
Downloads
- hash-addressed-cli-2.1.0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 1.0.0.0, 2.0.0.0, 2.1.0.0, 2.1.0.1 |
|---|---|
| Change log | changelog.md |
| Dependencies | base (>=4.16 && <4.18), bytestring (>=0.11.3 && <0.12), containers (>=0.6.5 && <0.7), cryptohash-sha256 (>=0.11.102 && <0.12), directory (>=1.3.6 && <1.4), filepath (>=1.4.2 && <1.5), hash-addressed (>=0.2.0 && <0.3), hash-addressed-cli, ini (>=0.4.2 && <0.5), optparse-applicative (>=0.16.1 && <0.17 || >=0.17.0 && <0.18), pipes (>=4.3.16 && <4.4), quaalude (>=0.0.0 && <0.1), resourcet (>=1.2.6 && <1.3 || >=1.3.0 && <1.4), safe-exceptions (>=0.1.7 && <0.2), text (>=1.2.5 && <1.3 || >=2.0.1 && <2.1), transformers (>=0.5.6 && <0.6), unordered-containers (>=0.2.17 && <0.3) [details] |
| License | Apache-2.0 |
| Copyright | 2023 Mission Valley Software LLC |
| Author | Chris Martin |
| Maintainer | Chris Martin, Julie Moronuki |
| Uploaded | by chris_martin at 2023-02-08T19:24:41Z |
| Category | Hash, Filesystem |
| Home page | https://github.com/typeclasses/hash-addressed-cli |
| Bug tracker | https://github.com/typeclasses/hash-addressed-cli/issues |
| Source repo | head: git clone git://github.com/typeclasses/hash-addressed-cli.git |
| Distributions | |
| Executables | hash-addressed |
| Downloads | 293 total (16 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs available [build log] Last success reported on 2023-02-08 [all 1 reports] |
Readme for hash-addressed-cli-2.1.0.1
[back to package description]The hash-addressed executable is a command-line interface for maintaining a
directory wherein each file's name is a hash of its content.
Initialization
In this demonstration, we initialize a SHA-256 hash-addressed directory at
/tmp/demo.
$ hash-addressed initialize --directory /tmp/demo --hash-function sha256
This created a configuration file:
$ cat /tmp/demo/.hash-addressed/config
version: 1
hash function: sha256
Writing
We can now use the hash-addressed write command to write files into this
directory. In the output we see the path to which the content was written.
$ echo "Test file 1" | hash-addressed write --target-directory /tmp/demo
/tmp/demo/ad7a409054a68314812ba3ad0e523a66593ab3404c81700d6f5c3601f0da830e
$ echo "Test file 2" | hash-addressed write --target-directory /tmp/demo
/tmp/demo/20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7
We can verify that the file was written and that indeed its name matches its SHA-256 checksum:
$ cat /tmp/demo/20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7
Test file 2
$ sha256sum /tmp/demo/20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7
20b39ca6ca85b53be73920532fd6f9cc164317646995839e2e54a6871dc13bf7
Symbolic links
A place to put links for demonstration:
$ mkdir --parents /tmp/demo-links
You can use the --link option with the write command to create symbolic
links to the hash-addressed content.
$ echo "whatever" | hash-addressed write --target-directory /tmp/demo --link /tmp/demo-links/link-1
/tmp/demo/cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411
Observing that the link was written:
$ readlink /tmp/demo-links/link-1
/tmp/demo/cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411
$ cat /tmp/demo-links/link-1
whatever
Verbosity
Use the --verbose flag to get some additional information, printed to the
standard error stream.
$ echo "Test file 3" | hash-addressed write --target-directory /tmp/demo --verbose
The hash function is sha256
/tmp/demo/efdbe264574c7440b80a2c4aaf15c18787a125b6223d05300841f32f46361e7f
One new file was added to the store.
$ echo "Test file 3" | hash-addressed write --target-directory /tmp/demo --verbose
The hash function is sha256
/tmp/demo/efdbe264574c7440b80a2c4aaf15c18787a125b6223d05300841f32f46361e7f
The file was already present in the store; no change was made.
Use the --quiet flag to suppress what is normally printed to the standard
output stream.
$ echo "Test file 4" | hash-addressed write --target-directory /tmp/demo --quiet
Fatal errors resulting in non-zero status code are always printed to the
standard error stream regardless of what command-line options are given. In the
following demonstration, the --link instruction succeeds the first time
(printing nothing because we use --quiet), but we see an error message the
second time because the link already exists.
$ echo "Test file 4" | hash-addressed write --target-directory /tmp/demo --quiet --link /tmp/demo-links/link-2
$ echo "Test file 4" | hash-addressed write --target-directory /tmp/demo --quiet --link /tmp/demo-links/link-2
Failed to create link /tmp/demo-links/link-2
File copying
Instead of reading from the standard input stream, hash-addressed can also
copy a file into the store using the --source-file option.
$ echo "file content" > /tmp/demo-file
$ hash-addressed write --source-file /tmp/demo-file --target-directory /tmp/demo
/tmp/demo/694b27f021c4861b3373cd5ddbc42695c056d0a4297d2d85e2dae040a84e61df
$ cat /tmp/demo/694b27f021c4861b3373cd5ddbc42695c056d0a4297d2d85e2dae040a84e61df
file content