Skip to content

Commit

Permalink
Merge pull request #225 from sorairolake/rewrite-in-derive-api
Browse files Browse the repository at this point in the history
Rewrite CLI using the derive API
  • Loading branch information
sharkdp authored Jul 16, 2024
2 parents 16cc5d9 + f8b87cc commit d2cc025
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 392 deletions.
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

0 comments on commit d2cc025

Please sign in to comment.