Skip to content

Commit e638471

Browse files
committed
Code refactor
1 parent 5858280 commit e638471

10 files changed

Lines changed: 109 additions & 293 deletions

File tree

.cargo/README.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
# chksum-cli
22

3-
[![GitHub](https://img.shields.io/badge/github-ferric--bytes%2Fchksum--cli-24292e?style=flat-square&logo=github "GitHub")](https://github.com/ferric-bytes/chksum-cli)
4-
[![Coverage](https://img.shields.io/codecov/c/gh/ferric-bytes/chksum-cli?style=flat-square&logo=codecov "Coverage")](https://app.codecov.io/gh/ferric-bytes/chksum-cli)
5-
[![MSRV](https://img.shields.io/badge/MSRV-1.66.0-informational?style=flat-square "MSRV")](https://github.com/ferric-bytes/chksum-cli/blob/master/Cargo.toml)
6-
[![deps.rs](https://deps.rs/crate/chksum-cli/0.3.2/status.svg?style=flat-square "deps.rs")](https://deps.rs/crate/chksum-cli/0.3.2)
3+
[![GitHub](https://img.shields.io/badge/github-chksum--rs%2Fcli-24292e?style=flat-square&logo=github "GitHub")](https://github.com/chksum-rs/cli)
4+
[![Build](https://img.shields.io/github/actions/workflow/status/chksum-rs/cli/rust.yml?branch=master&style=flat-square&logo=github "Build")](https://github.com/chksum-rs/cli/actions/workflows/rust.yml)
5+
[![MSRV](https://img.shields.io/badge/MSRV-1.70.0-informational?style=flat-square "MSRV")](https://github.com/chksum-rs/cli/blob/master/Cargo.toml)
6+
[![deps.rs](https://deps.rs/crate/chksum/0.4.0/status.svg?style=flat-square "deps.rs")](https://deps.rs/crate/chksum/0.4.0)
77
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg?style=flat-square "unsafe forbidden")](https://github.com/rust-secure-code/safety-dance)
8-
[![LICENSE](https://img.shields.io/github/license/ferric-bytes/chksum-cli?style=flat-square "LICENSE")](https://github.com/ferric-bytes/chksum-cli/blob/master/LICENSE)
8+
[![LICENSE](https://img.shields.io/github/license/chksum-rs/cli?style=flat-square "LICENSE")](https://github.com/chksum-rs/cli/blob/master/LICENSE)
99

1010
A simple checksum calculator.
1111

1212
## Motivation
1313

14-
There are variety of tools that allows calculate hash digests.
15-
16-
However tools like `md5sum`, `sha1sum`, `b2sum`, `sha224sum` and others offer only file-based checksums.
14+
Various tools like `md5sum`, `sha1sum`, `b2sum`, `sha224sum`, etc., allow users to calculate file-based hash digests. However, these tools focus on file-level checksums, making it cumbersome to handle scenarios like calculating digests on-the-fly while writing data. This motivated the creation of `chksum` to offer a simplified interface for such use cases.
1715

1816
```shell
1917
find dir/ -type f | sort | xargs cat | sha224sum
2018
```
2119

22-
Instead you can just use `chksum` with preffered hash algorithm.
20+
With `chksum`, you can achieve the same result with your preferred hash algorithm:
2321

2422
```sh
2523
chksum sha2-224 dir/
2624
```
2725

28-
## Features
26+
## Key Features
2927

30-
- Written in pure Rust
31-
- No unsafe code
32-
- Configurable via Cargo features
33-
- Multithread
28+
* Implemented in pure Rust
29+
* No unsafe code
30+
* Configurable via Cargo features
31+
* Multithreaded
3432

3533
## Installation
3634

37-
Use [`cargo install`](https://doc.rust-lang.org/cargo/commands/cargo-install.html) to install `chksum` binary in `$HOME/.cargo/bin` directory.
35+
Install the `chksum` binary using [`cargo install`](https://doc.rust-lang.org/cargo/commands/cargo-install.html):
3836

3937
```shell
4038
cargo install chksum-cli
4139
```
4240

4341
## Usage
4442

43+
### General Help
44+
4545
```shell
4646
$ chksum help
4747
A simple checksum calculator.
@@ -63,6 +63,8 @@ Options:
6363
-V, --version Print version
6464
```
6565

66+
### Help for a Specific Algorithm
67+
6668
```shell
6769
$ chksum help sha2-224
6870
Calculate SHA-2 224 digest
@@ -78,21 +80,21 @@ Options:
7880
-h, --help Print help
7981
```
8082

81-
### File
83+
### File Processing
8284

8385
```shell
8486
$ chksum sha2-224 LICENSE
8587
LICENSE: 99258bca0d23c69388dd53412f1009132753b89459359a401a6ed158
8688
```
8789

88-
### Directory
90+
### Directory Processing
8991

9092
```shell
9193
$ chksum sha1 src/
9294
src/: 03e4ae615c034f5db47c72bd5c6c9e5bf450a2bd
9395
```
9496

95-
### Standard input
97+
### Standard Input Processing
9698

9799
```shell
98100
$ echo -n admin1 | chksum md5 --stdin
@@ -101,17 +103,17 @@ $ echo -n admin1 | chksum md5 --stdin
101103

102104
## Library
103105

104-
Check [`chksum`](https://crates.io/crates/chksum) crate to see the library that allows you to calculate digests of files and directories with easy-to-use interface.
106+
Check out the [`chksum`](https://crates.io/crates/chksum) crate to see the library that allows you to calculate digests of files and directories with an easy-to-use interface.
105107

106-
## Hash algorithms
108+
## Hash Algorithms
107109

108-
Implemented hash algorithms:
110+
This binary provides implementations for the following hash algorithms:
109111

110112
* MD5 - [RFC 1321: The MD5 Message-Digest Algorithm](https://tools.ietf.org/html/rfc1321)
111113
* SHA-1 - [RFC 3174: US Secure Hash Algorithm 1 (SHA1)](https://tools.ietf.org/html/rfc3174)
112114
* SHA-2 family (SHA-224, SHA-256, SHA-386, SHA-512) - [FIPS PUB 180-4: Secure Hash Standard](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf)
113115

114-
## Feature flags
116+
## Features
115117

116118
### Algorithms
117119

@@ -123,19 +125,18 @@ Implemented hash algorithms:
123125
* `sha2-384`: Enables only SHA-2 384 hash algorithm.
124126
* `sha2-512`: Enables only SHA-2 512 hash algorithm.
125127

126-
By default all of them are enabled.
128+
By default, all of them are enabled.
127129

128-
### Options
130+
### Extra Options
129131

130132
* `color`: Enables colored output.
131-
* `unstable`: Enables unstable options.
132133

133-
By default only `color` is enabled.
134+
By default, all of them are enabled.
134135

135136
## Disclaimer
136137

137-
Code is under development. The interface may change in the future.
138+
The code is under development, and the interface may change in the future.
138139

139140
## License
140141

141-
MIT
142+
This crate is licensed under the MIT License.

.github/workflows/rust.yml

Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
push:
1111
branches:
1212
- master
13-
- dev
1413
paths:
1514
- ".github/workflows/*.yml"
1615
- "Cargo.toml"
@@ -19,7 +18,6 @@ on:
1918
pull_request:
2019
branches:
2120
- master
22-
- dev
2321
paths:
2422
- ".github/workflows/*.yml"
2523
- "Cargo.toml"
@@ -55,55 +53,14 @@ jobs:
5553
token: ${{ secrets.GITHUB_TOKEN }}
5654
args: --all-features -- --deny clippy::cargo
5755

58-
deny:
59-
runs-on: ubuntu-latest
60-
name: Deny
61-
steps:
62-
- name: Repository checkout
63-
uses: actions/checkout@v3
64-
- name: Setup Rust
65-
uses: actions-rs/toolchain@v1
66-
with:
67-
toolchain: nightly
68-
default: true
69-
profile: minimal
70-
- name: Install cargo deny
71-
uses: actions-rs/install@v0.1
72-
with:
73-
crate: cargo-deny
74-
- name: Run cargo deny
75-
uses: actions-rs/cargo@v1
76-
with:
77-
command: deny
78-
args: --all-features check
79-
80-
security-audit:
81-
name: Security Audit
82-
runs-on: ubuntu-latest
83-
steps:
84-
- name: Repository checkout
85-
uses: actions/checkout@v3
86-
- name: Setup Rust
87-
uses: actions-rs/toolchain@v1
88-
with:
89-
toolchain: stable
90-
default: true
91-
profile: minimal
92-
- name: Run audit check
93-
uses: actions-rs/audit-check@v1
94-
with:
95-
token: ${{ secrets.GITHUB_TOKEN }}
96-
9756
build-and-test-linux:
9857
needs:
99-
- deny
10058
- lint
101-
- security-audit
10259
runs-on: ubuntu-latest
10360
strategy:
10461
fail-fast: false
10562
matrix:
106-
toolchain: [1.66.0, stable, nightly]
63+
toolchain: [1.70.0, stable, nightly]
10764
name: "Build and test (OS: Linux, Toolchain: ${{ matrix.toolchain }})"
10865
steps:
10966
- name: Repository checkout
@@ -127,14 +84,12 @@ jobs:
12784

12885
build-and-test-macos:
12986
needs:
130-
- deny
13187
- lint
132-
- security-audit
13388
runs-on: macos-latest
13489
strategy:
13590
fail-fast: false
13691
matrix:
137-
toolchain: [1.66.0, stable, nightly]
92+
toolchain: [1.70.0, stable, nightly]
13893
name: "Build and test (OS: MacOS, Toolchain: ${{ matrix.toolchain }})"
13994
steps:
14095
- name: Repository checkout
@@ -158,14 +113,12 @@ jobs:
158113

159114
build-and-test-windows:
160115
needs:
161-
- deny
162116
- lint
163-
- security-audit
164117
runs-on: windows-latest
165118
strategy:
166119
fail-fast: false
167120
matrix:
168-
toolchain: [1.66.0, stable, nightly]
121+
toolchain: [1.70.0, stable, nightly]
169122
name: "Build and test (OS: Windows, Toolchain: ${{ matrix.toolchain }})"
170123
steps:
171124
- name: Repository checkout
@@ -186,32 +139,3 @@ jobs:
186139
with:
187140
command: test
188141
args: --all-features --verbose
189-
190-
coverage:
191-
needs:
192-
- deny
193-
- lint
194-
- security-audit
195-
runs-on: ubuntu-latest
196-
name: Coverage
197-
steps:
198-
- name: Repository checkout
199-
uses: actions/checkout@v3
200-
- name: Setup Rust
201-
uses: actions-rs/toolchain@v1
202-
with:
203-
toolchain: nightly
204-
default: true
205-
profile: minimal
206-
- name: Install cargo tarpaulin
207-
uses: actions-rs/install@v0.1
208-
with:
209-
crate: cargo-tarpaulin
210-
- name: Run cargo tarpaulin
211-
run: cargo tarpaulin --all-features --engine llvm --fail-under 50 --follow-exec --ignore-tests --out xml --timeout 120
212-
- name: Upload to codecov.io
213-
if: ${{ always() }}
214-
uses: codecov/codecov-action@v3
215-
with:
216-
token: ${{ secrets.CODECOV_TOKEN }}
217-
fail_ci_if_error: true

CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.0] - 2023-12-21
9+
10+
### Changed
11+
12+
- Code refactor.
13+
814
## [0.3.2] - 2023-08-21
915

1016
### Added
@@ -60,7 +66,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6066

6167
- Initial release.
6268

63-
[0.3.2]: https://github.com/ferric-bytes/chksum-cli/compare/v0.3.1...v0.3.2
64-
[0.3.1]: https://github.com/ferric-bytes/chksum-cli/compare/v0.3.0...v0.3.1
65-
[0.3.0]: https://github.com/ferric-bytes/chksum-cli/compare/v0.2.0...v0.3.0
66-
[0.2.0]: https://github.com/ferric-bytes/chksum-cli/releases/tag/v0.2.0
69+
[0.4.0]: https://github.com/chksum-rs/cli/compare/v0.3.2...v0.4.0
70+
[0.3.2]: https://github.com/chksum-rs/cli/compare/v0.3.1...v0.3.2
71+
[0.3.2]: https://github.com/chksum-rs/cli/compare/v0.3.1...v0.3.2
72+
[0.3.1]: https://github.com/chksum-rs/cli/compare/v0.3.0...v0.3.1
73+
[0.3.0]: https://github.com/chksum-rs/cli/compare/v0.2.0...v0.3.0
74+
[0.2.0]: https://github.com/chksum-rs/cli/releases/tag/v0.2.0

Cargo.toml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "chksum-cli"
3-
version = "0.3.2"
3+
version = "0.4.0"
44
authors = ["Konrad Goławski <konrad@golawski.it>"]
55
edition = "2021"
6-
rust-version = "1.66.0"
6+
rust-version = "1.70.0"
77
description = "A simple checksum calculator."
88
readme = ".cargo/README.md"
9-
repository = "https://github.com/ferric-bytes/chksum-cli"
9+
repository = "https://github.com/chksum-rs/cli"
1010
license = "MIT"
1111
keywords = ["checksum", "digest", "directory-checksum", "file-checksum", "hash"]
1212
categories = ["command-line-utilities", "cryptography", "filesystem"]
@@ -19,31 +19,28 @@ all-features = true
1919
rustdoc-args = ["--cfg", "docsrs"]
2020

2121
[dependencies]
22-
anyhow = "1.0.72"
23-
chksum = "0.2.2"
24-
clap = { version = "4.3.19", features = ["cargo", "derive", "wrap_help", "unicode"] }
25-
colored = { version = "2.0.4", optional = true }
22+
anyhow = "1.0.76"
23+
chksum = { version = "0.3.0", default-features = false }
24+
clap = { version = "4.4.11", features = ["cargo", "derive", "wrap_help", "unicode"] }
25+
colored = { version = "2.1.0", optional = true }
2626
exitcode = "1.1.2"
2727
rayon = "1.7.0"
2828

2929
[dev-dependencies]
3030
assert_cmd = { version = "2.0.12", features = ["color-auto"] }
3131
assert_fs = { version = "1.0.13", features = ["color-auto"] }
32-
thiserror = "1.0.44"
32+
thiserror = "1.0.51"
3333

3434
[features]
3535
default = [
3636
# compilation
3737
"color",
3838
# algorithms
39-
"md5",
40-
"sha1",
41-
"sha2",
39+
"md5", "sha1", "sha2",
4240
]
4341

4442
# compilation
4543
color = ["colored"]
46-
unstable = ["chksum/unstable"]
4744

4845
# algorithms
4946
md5 = ["chksum/md5"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Konrad Goławski
3+
Copyright (c) 2020-2023 Konrad Goławski
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)