diff options
author | Julian Sitkevich <sitkevij@gmail.com> | 2019-01-18 20:58:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-18 20:58:24 -0800 |
commit | bd512512bafc1e162eff33ba7c281b0d4f5a4087 (patch) | |
tree | c3b4767e289e327cdbc46c0b03c55ae2b8cf4ce5 | |
parent | 93b11a84bd1dffb3a5b17499cccb236904d5c764 (diff) | |
parent | 24a290058e39253a8f7d38d974814029d854ccea (diff) |
Merge pull request #9 from sitkevij/project-change/name
new crates.io project
-rw-r--r-- | .dockerignore | 1 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | Cargo.lock | 131 | ||||
-rw-r--r-- | Cargo.toml | 18 | ||||
-rw-r--r-- | Dockerfile | 4 | ||||
-rw-r--r-- | Dockerfile.alpine | 6 | ||||
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | README.md | 79 | ||||
-rw-r--r-- | assets/hex_screenshot_macos_format_b.png (renamed from tests/files/hex_screenshot_macos_format_b.png) | bin | 50749 -> 50749 bytes | |||
-rw-r--r-- | assets/hex_screenshot_macos_format_default.png (renamed from tests/files/hex_screenshot_macos_format_default.png) | bin | 58901 -> 58901 bytes | |||
-rw-r--r-- | assets/hex_screenshot_macos_format_o.png (renamed from tests/files/hex_screenshot_macos_format_o.png) | bin | 55633 -> 55633 bytes | |||
-rw-r--r-- | src/lib.rs | 6 | ||||
-rw-r--r-- | src/main.rs | 9 | ||||
-rw-r--r-- | tests/files/alphanumeric-zh.txt | 2 |
16 files changed, 219 insertions, 51 deletions
diff --git a/.dockerignore b/.dockerignore index 7cfc043..9f18cf5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ target/ Cargo.lock LICENSE +Makefile README.md **/*.rs.bk
\ No newline at end of file @@ -4,7 +4,7 @@ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock +# Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk diff --git a/.travis.yml b/.travis.yml index 8aeebcd..4435886 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,4 @@ matrix: script: - cargo build --verbose --all - cargo test --verbose --all -- --nocapture - - docker build -t sitkevij/stretch-slim:hex-0.1.3 . + - docker build -t sitkevij/stretch-slim:hex-0.2.0 . diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a8bc98c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,131 @@ +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "clap" +version = "2.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hx" +version = "0.2.0" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.47" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_syscall" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "strsim" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "textwrap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" +"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" @@ -1,10 +1,16 @@ [package] -name = "hex" -version = "0.1.3" -authors = ["author https://github.com/sitkevij"] -description = "hexdump utility." +authors = ["sitkevij"] +categories = ["command-line-utilities","debugging"] +description = "Futuristic take on hexdump, made in Rust." +include = ["src/**/*","Cargo.toml","Cargo.lock"] homepage = "https://github.com/sitkevij/hex" -repository = "https://github.com/sitkevij/hex" +keywords = ["hexdump", "hexadecimal", "tools", "ascii", "hex"] +license = "MIT" +name = "hx" +version = "0.2.0" + +[badges] +travis-ci = { repository = "sitkevij/hex", branch = "master" } # The development profile, used for `cargo build`. [profile.dev] @@ -20,4 +26,4 @@ opt-level = 3 [dependencies] clap = "2.31.1" -ansi_term = "0.11"
\ No newline at end of file +ansi_term = "0.11" @@ -1,12 +1,12 @@ FROM debian:stretch-slim WORKDIR /root -LABEL org.label-schema.name="hex" \ +LABEL org.label-schema.name="hx" \ org.label-schema.description="Futuristic take on hexdump, made in rust" \ org.label-schema.url="https://hub.docker.com/r/sitkevij/hex/" \ org.label-schema.usage="https://github.com/sitkevij/hex/blob/master/README.md" \ org.label-schema.vcs-url="https://github.com/sitkevij/hex" \ org.label-schema.vendor="sitkevij" \ - org.label-schema.version="0.1.3" \ + org.label-schema.version="0.2.0" \ maintainer="https://github.com/sitkevij" RUN apt-get update && \ apt-get install --no-install-recommends -y \ diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 43a3ab5..81ea1d3 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -1,13 +1,13 @@ FROM sitkevij/alpine-rust:rustup.rs -ENTRYPOINT ["hex"] +ENTRYPOINT ["hx"] WORKDIR /tmp/hex -LABEL org.label-schema.name="hex" \ +LABEL org.label-schema.name="hx" \ org.label-schema.description="Futuristic take on hexdump, made in rust" \ org.label-schema.url="https://hub.docker.com/r/sitkevij/hex/" \ org.label-schema.usage="https://github.com/sitkevij/hex/blob/master/README.md" \ org.label-schema.vcs-url="https://github.com/sitkevij/hex" \ org.label-schema.vendor="sitkevij" \ - org.label-schema.version="0.1.0" \ + org.label-schema.version="0.2.0" \ maintainer="https://github.com/sitkevij" # RUN echo "export PATH=$PATH:~/.cargo/bin" >> ~/.profile && source ~/.profile COPY . . @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Julian Sitkevich +Copyright (c) 2018 sitkevij Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -9,14 +9,14 @@ DEBUG_DIR = $(TARGET_DIR)/debug RELEASE_DIR = $(TARGET_DIR)/release RLS_DIR = $(TARGET_DIR)/rls INSTALL_DIR = /usr/local/bin -BINARY = hex +BINARY = hx all: fmt test clean fmt: cargo +nightly fmt --verbose -debug: test +debug: cargo build release: test @@ -33,9 +33,9 @@ install-force: clean release debug test cargo install --path . --force docker: - docker build -t sitkevij/stretch-slim:hex-0.1.3 . + docker build -t sitkevij/stretch-slim:$(BINARY)-0.2.0 . clean: ## Remove all artifacts rm -rf $(DEBUG_DIR) rm -rf $(RELEASE_DIR) - rm -rf $(RLS_DIR)
\ No newline at end of file + rm -rf $(RLS_DIR) @@ -1,10 +1,11 @@ -# hex +# hex (hx) + Futuristic take on hexdump. `hex` takes a file as input and outputs a hexadecimal colorized view to stdout. ``` -$ hex -c12 tests/files/alphanumeric.txt +$ hx -c12 tests/files/alphanumeric.txt 0x000000: 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6a 0x6b 0x69 abcdefghijki 0x00000c: 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 lmnopqrstuvw 0x000018: 0x78 0x79 0x7a 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 xyz012345678 @@ -17,68 +18,96 @@ $ hex -c12 tests/files/alphanumeric.txt [![build](https://travis-ci.org/sitkevij/hex.svg?branch=master)](https://travis-ci.org/sitkevij/hex) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fsitkevij%2Fhex.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fsitkevij%2Fhex?ref=badge_shield) +## quick links + +* [install](#install) +* [features](#features) +* [license](#license) + ## examples ### lower hex format -fx -`$ hex src/main.rs` -![lower hex output format](https://raw.githubusercontent.com/sitkevij/hex/master/tests/files/hex_screenshot_macos_format_default.png "default hex output format") +`$ hx src/main.rs` + +![lower hex output format](https://raw.githubusercontent.com/sitkevij/hex/master/assets/hex_screenshot_macos_format_default.png "default output format") + +### binary hex format -fb -### binary format -fb -`$ hex -fb -c4 src/main.rs` +`$ hx -fb -c4 src/main.rs` -![binary hex output format](https://raw.githubusercontent.com/sitkevij/hex/master/tests/files/hex_screenshot_macos_format_b.png) +![binary hex output format](https://raw.githubusercontent.com/sitkevij/hex/master/assets/hex_screenshot_macos_format_b.png) -### octal format -fo -`$ hex -fo -c8 src/main.rs` +### octal hex format -fo -![octal hex output format](https://raw.githubusercontent.com/sitkevij/hex/master/tests/files/hex_screenshot_macos_format_o.png) +`$ hx -fo -c8 src/main.rs` -# install +![octal hex output format](https://raw.githubusercontent.com/sitkevij/hex/master/assets/hex_screenshot_macos_format_o.png) -From within the `hex` source code directory, simply execute: +## install + +### crates.io install + +If `cargo` is already installed, simply: +``` +cargo install hx +``` + +### source install + +From within the `hx` source code directory, simply execute: ``` make install ``` -This will run the followng `cargo` commands: + +This will run the following `cargo` commands: ``` cargo build --release cargo test --verbose --all -- --nocapture cargo install --path . ``` -Which will compile the release version, run tests and install release binary to `<USERDIR>/.cargo/bin/hex`. -If `<USERDIR>/.cargo/bin` is part of the `PATH` evironment variable, `hex` should be able to be executed anywhere in the shell. +Which will compile the release version, run tests and install release binary to `<USERDIR>/.cargo/bin/hx`. + +If `<USERDIR>/.cargo/bin` is part of the `PATH` evironment variable, `hx` should be able to be executed anywhere in the shell. -# feature: output arrays in rust, c or golang +## features -`hex` has a feature which can output the input file bytes as source code arrays. +### output arrays in `rust`, `c` or `golang` + +`hx` has a feature which can output the input file bytes as source code arrays. For example: -### rust array: -ar +#### rust array: -ar + ``` -$ hex -ar -c8 tests/files/tiny.txt +$ hx -ar -c8 tests/files/tiny.txt let ARRAY: [u8; 3] = [ 0x69, 0x6c, 0x0a ]; ``` -### c array: -ac +#### c array: -ac + ``` -$ hex -ac -c8 tests/files/tiny.txt +$ hx -ac -c8 tests/files/tiny.txt unsigned char ARRAY[3] = { 0x69, 0x6c, 0x0a }; ``` -### golang array: -ag +#### golang array: -ag + ``` -$ hex -ag -c8 tests/files/tiny.txt +$ hx -ag -c8 tests/files/tiny.txt a := [3]byte{ 0x69, 0x6c, 0x0a, } ``` -## License -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fsitkevij%2Fhex.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fsitkevij%2Fhex?ref=badge_large)
\ No newline at end of file +## license + +MIT + +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fsitkevij%2Fhex.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fsitkevij%2Fhex?ref=badge_large) diff --git a/tests/files/hex_screenshot_macos_format_b.png b/assets/hex_screenshot_macos_format_b.png Binary files differindex f91eb60..f91eb60 100644 --- a/tests/files/hex_screenshot_macos_format_b.png +++ b/assets/hex_screenshot_macos_format_b.png diff --git a/tests/files/hex_screenshot_macos_format_default.png b/assets/hex_screenshot_macos_format_default.png Binary files differindex 3e5d06c..3e5d06c 100644 --- a/tests/files/hex_screenshot_macos_format_default.png +++ b/assets/hex_screenshot_macos_format_default.png diff --git a/tests/files/hex_screenshot_macos_format_o.png b/assets/hex_screenshot_macos_format_o.png Binary files differindex c5e2fe8..c5e2fe8 100644 --- a/tests/files/hex_screenshot_macos_format_o.png +++ b/assets/hex_screenshot_macos_format_o.png @@ -32,7 +32,6 @@ use std::io::Read; /// e ⇒ LowerExp /// E ⇒ UpperExp /// evaulate for traits implementation -/// https://stackoverflow.com/questions/27650312/show-u8-slice-in-hex-representation #[derive(Copy, Clone, Debug)] pub enum Format { /// octal format @@ -341,10 +340,6 @@ pub fn run(matches: ArgMatches) -> Result<(), Box<::std::error::Error>> { /// Buffer to array. /// -/// (https://rustbyexample.com/primitives/array.html) -/// (https://stackoverflow.com/questions/39464237/whats-the-idiomatic-way-reference-bufreader-bufwriter-when-passing-between-funct) -/// (https://stackoverflow.com/questions/39935158/bufreader-move-after-for-loop-with-bufreader-lines) -/// /// # Arguments /// /// * `buf` - Buffer to be read. @@ -383,7 +378,6 @@ pub fn buf_to_array( mod tests { use super::*; /// @see (https://users.rust-lang.org/t/how-to-test-output-to-stdout/4877/6) - /// @see (https://rustbyexample.com/hello/print/print_display.html) #[test] fn test_offset() { let b: u64 = 0x6; diff --git a/src/main.rs b/src/main.rs index 7e379c8..a8703b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,10 +6,15 @@ use std::process; /// Central application entry point. fn main() { + let desc: &str = &format!( + "{}\n{}", + env!("CARGO_PKG_DESCRIPTION"), + env!("CARGO_PKG_HOMEPAGE") + ) + .to_string(); let app = App::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) - .about(env!("CARGO_PKG_DESCRIPTION")) // CARGO_PKG_HOMEPAGE - .author(env!("CARGO_PKG_AUTHORS")) + .about(desc) .arg( Arg::with_name("cols") .short("c") diff --git a/tests/files/alphanumeric-zh.txt b/tests/files/alphanumeric-zh.txt new file mode 100644 index 0000000..4fb5bea --- /dev/null +++ b/tests/files/alphanumeric-zh.txt @@ -0,0 +1,2 @@ +诶 比 西 迪 伊 艾弗 吉 艾尺 艾 杰 开 艾勒 艾马 艾娜 +一 二 三 四 五 六 七 九 十 |