Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite CLI using the derive API #225

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

## Other

- Rewrite CLI using the derive API, see #225 (@sorairolake)


# v0.14.0

Expand Down
21 changes: 20 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ terminal_size = "0.2"

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

[dev-dependencies]
assert_cmd = "2.0"
Expand Down
1 change: 0 additions & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::fs;
use std::io::{self, copy, sink, Read, Seek, SeekFrom};

Expand Down
27 changes: 24 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pub use input::*;

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

use clap::ValueEnum;

pub enum Base {
Binary,
Octal,
Expand All @@ -22,17 +24,30 @@ pub enum ByteCategory {
NonAscii,
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug, Default, ValueEnum)]
#[non_exhaustive]
pub enum CharacterTable {
/// Show printable ASCII characters as-is, '⋄' for NULL bytes, ' ' for
/// space, '_' for other ASCII whitespace, '•' for other ASCII characters,
/// and '×' for non-ASCII bytes.
#[default]
Default,

/// Show printable ASCII as-is, ' ' for space, '.' for everything else.
Ascii,

/// Uses code page 437 (for non-ASCII bytes).
#[value(name = "codepage-437")]
CP437,
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug, Default, ValueEnum)]
pub enum Endianness {
/// Print out groups in little-endian format.
Little,

/// Print out groups in big-endian format.
#[default]
Big,
}

Expand Down Expand Up @@ -104,10 +119,16 @@ struct BorderElements {
right_corner: char,
}

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug, Default, ValueEnum)]
pub enum BorderStyle {
/// Draw a border with Unicode characters.
#[default]
Unicode,

/// Draw a border with ASCII characters.
Ascii,

/// Do not draw a border at all.
None,
}

Expand Down
Loading
Loading