Skip to content

Commit d2cc025

Browse files
authored
Merge pull request #225 from sorairolake/rewrite-in-derive-api
Rewrite CLI using the derive API
2 parents 16cc5d9 + f8b87cc commit d2cc025

File tree

6 files changed

+336
-392
lines changed

6 files changed

+336
-392
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
## Other
1010

11+
- Rewrite CLI using the derive API, see #225 (@sorairolake)
12+
1113

1214
# v0.14.0
1315

Cargo.lock

+20-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ terminal_size = "0.2"
2222

2323
[dependencies.clap]
2424
version = "4"
25-
default-features = false
26-
features = ["std", "suggestions", "color", "wrap_help", "cargo", "help", "usage", "error-context"]
25+
features = ["derive", "wrap_help"]
2726

2827
[dev-dependencies]
2928
assert_cmd = "2.0"

src/input.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::convert::TryFrom;
21
use std::fs;
32
use std::io::{self, copy, sink, Read, Seek, SeekFrom};
43

src/lib.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub use input::*;
66

77
use std::io::{self, BufReader, Read, Write};
88

9+
use clap::ValueEnum;
10+
911
pub enum Base {
1012
Binary,
1113
Octal,
@@ -22,17 +24,30 @@ pub enum ByteCategory {
2224
NonAscii,
2325
}
2426

25-
#[derive(Copy, Clone)]
27+
#[derive(Copy, Clone, Debug, Default, ValueEnum)]
2628
#[non_exhaustive]
2729
pub enum CharacterTable {
30+
/// Show printable ASCII characters as-is, '⋄' for NULL bytes, ' ' for
31+
/// space, '_' for other ASCII whitespace, '•' for other ASCII characters,
32+
/// and '×' for non-ASCII bytes.
33+
#[default]
2834
Default,
35+
36+
/// Show printable ASCII as-is, ' ' for space, '.' for everything else.
2937
Ascii,
38+
39+
/// Uses code page 437 (for non-ASCII bytes).
40+
#[value(name = "codepage-437")]
3041
CP437,
3142
}
3243

33-
#[derive(Copy, Clone)]
44+
#[derive(Copy, Clone, Debug, Default, ValueEnum)]
3445
pub enum Endianness {
46+
/// Print out groups in little-endian format.
3547
Little,
48+
49+
/// Print out groups in big-endian format.
50+
#[default]
3651
Big,
3752
}
3853

@@ -104,10 +119,16 @@ struct BorderElements {
104119
right_corner: char,
105120
}
106121

107-
#[derive(Clone, Copy)]
122+
#[derive(Clone, Copy, Debug, Default, ValueEnum)]
108123
pub enum BorderStyle {
124+
/// Draw a border with Unicode characters.
125+
#[default]
109126
Unicode,
127+
128+
/// Draw a border with ASCII characters.
110129
Ascii,
130+
131+
/// Do not draw a border at all.
111132
None,
112133
}
113134

0 commit comments

Comments
 (0)