summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian Sitkevich <1553398+sitkevij@users.noreply.github.com>2020-11-22 09:42:47 -0800
committerGitHub <noreply@github.com>2020-11-22 09:42:47 -0800
commitb0a844a83c9c15f2416fa7e5748347fbe1ee4a77 (patch)
tree1387bfc70dbe5a4da6680ae9650087a09f5d32c6
parent2e34704eba10e0619d5ddcb5f98cce0d06f53d9e (diff)
parentd7d381f01932806d47d3f21c26428654b591b9f6 (diff)
Merge pull request #51 from sitkevij/developv0.4.0
develop 0.4.0
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md17
-rw-r--r--.github/workflows/ci.yml9
-rw-r--r--.github/workflows/docker.yml29
-rw-r--r--.gitignore3
-rw-r--r--BADGING.md5
-rw-r--r--Cargo.lock135
-rw-r--r--Cargo.toml14
-rw-r--r--Dockerfile25
-rw-r--r--Dockerfile.alpine22
-rw-r--r--Makefile30
-rw-r--r--README.md25
-rw-r--r--src/lib.rs29
-rw-r--r--src/main.rs6
13 files changed, 212 insertions, 137 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index dd84ea7..3205926 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -12,6 +12,7 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
+
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
@@ -24,15 +25,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- - OS: [e.g. iOS]
- - Browser [e.g. chrome, safari]
- - Version [e.g. 22]
+
+- OS: [e.g. iOS]
+- Browser [e.g. chrome, safari]
+- Version [e.g. 22]
**Smartphone (please complete the following information):**
- - Device: [e.g. iPhone6]
- - OS: [e.g. iOS8.1]
- - Browser [e.g. stock browser, safari]
- - Version [e.g. 22]
+
+- Device: [e.g. iPhone6]
+- OS: [e.g. iOS8.1]
+- Browser [e.g. stock browser, safari]
+- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e4cd193..ed9a012 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,6 +1,10 @@
name: CI
on:
pull_request:
+ branches:
+ - develop
+ - main
+ - master
push:
branches:
- develop
@@ -9,6 +13,7 @@ on:
env:
RUST_BACKTRACE: full
+ NO_COLOR: 1
jobs:
test:
@@ -36,10 +41,10 @@ jobs:
- run: cargo test --verbose --all -- --nocapture
- run: cargo install hyperfine
- run: echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." | target/release/hx
- - run: hyperfine --warmup 20 "echo 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' | target/release/hx"
- # - run: cargo test --verbose --all -- --nocapture
+ - run: hyperfine -i --warmup 20 "echo 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' | target/release/hx"
# - run: cargo test --verbose --workspace --all-features
# - run: cargo test --verbose --workspace --no-default-features
+ # see https://github.com/actions/upload-release-asset
clippy:
name: Lint with clippy
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 0000000..e8a82a5
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,29 @@
+name: docker
+
+on:
+ push:
+ branches:
+ - main
+ - master
+
+jobs:
+ main:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ - name: Build and push
+ id: docker_build
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ tags: sitkevij/hx:latest
+ - name: Image digest
+ run: echo ${{ steps.docker_build.outputs.digest }}
diff --git a/.gitignore b/.gitignore
index e87a0b4..91a6361 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,4 +13,5 @@
# ci code coverage
tarpaulin-report.html
-cobertura.xml \ No newline at end of file
+cobertura.xml
+trend.svg \ No newline at end of file
diff --git a/BADGING.md b/BADGING.md
new file mode 100644
index 0000000..a7850c2
--- /dev/null
+++ b/BADGING.md
@@ -0,0 +1,5 @@
+[![build](https://travis-ci.org/sitkevij/hex.svg?branch=master)](https://travis-ci.org/sitkevij/hex)
+[![coverage](https://img.shields.io/codecov/c/github/sitkevij/hex/master.svg)](https://codecov.io/gh/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)
+
+[![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
diff --git a/Cargo.lock b/Cargo.lock
index 6819a49..ea174b4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,197 +4,212 @@
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi",
+]
+
+[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi",
]
[[package]]
name = "assert_cmd"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da"
dependencies = [
- "doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "predicates 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "doc-comment",
+ "predicates",
+ "predicates-core",
+ "predicates-tree",
+ "wait-timeout",
]
[[package]]
name = "atty"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
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)",
+ "libc",
+ "termion",
+ "winapi",
]
[[package]]
name = "bitflags"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
[[package]]
name = "clap"
-version = "2.32.0"
+version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
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)",
+ "ansi_term 0.11.0",
+ "atty",
+ "bitflags",
+ "strsim",
+ "textwrap",
+ "unicode-width",
+ "vec_map",
]
[[package]]
name = "difference"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
[[package]]
name = "doc-comment"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "hx"
-version = "0.3.2"
+version = "0.4.0"
dependencies = [
- "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "assert_cmd 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ansi_term 0.12.1",
+ "assert_cmd",
+ "atty",
+ "clap",
+ "no_color",
]
[[package]]
name = "libc"
version = "0.2.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476"
+
+[[package]]
+name = "no_color"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bdf5e47de39a83b44018b2ee76a7a2643f37738ee44da99e145bc9804b341dd4"
[[package]]
name = "predicates"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a"
dependencies = [
- "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "difference",
+ "predicates-core",
]
[[package]]
name = "predicates-core"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178"
[[package]]
name = "predicates-tree"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124"
dependencies = [
- "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "predicates-core",
+ "treeline",
]
[[package]]
name = "redox_syscall"
version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2"
[[package]]
name = "redox_termios"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
dependencies = [
- "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall",
]
[[package]]
name = "strsim"
-version = "0.7.0"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "termion"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
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)",
+ "libc",
+ "redox_syscall",
+ "redox_termios",
]
[[package]]
name = "textwrap"
-version = "0.10.0"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
- "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width",
]
[[package]]
name = "treeline"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
[[package]]
name = "unicode-width"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
[[package]]
name = "vec_map"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
[[package]]
name = "wait-timeout"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
dependencies = [
- "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc",
]
[[package]]
name = "winapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
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)",
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[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 assert_cmd 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da"
-"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 difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
-"checksum doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
-"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476"
-"checksum predicates 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a"
-"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178"
-"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124"
-"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 treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
-"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 wait-timeout 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
-"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"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/Cargo.toml b/Cargo.toml
index ee6ab10..5e9965e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,18 +2,16 @@
authors = ["sitkevij"]
categories = ["command-line-utilities","development-tools"]
description = "Futuristic take on hexdump, made in Rust."
-include = ["src/**/*","Cargo.toml","Cargo.lock"]
repository = "https://github.com/sitkevij/hex"
keywords = ["hexdump", "hexadecimal", "tools", "ascii", "hex"]
+include = ["src/**/*","Cargo.toml","Cargo.lock", "README.md"]
license = "MIT"
name = "hx"
-version = "0.3.2"
+readme ="README.md"
+version = "0.4.0"
edition = "2018"
# see https://doc.rust-lang.org/cargo/reference/manifest.html
-[badges]
-travis-ci = { repository = "sitkevij/hex", branch = "master" }
-codecov = { repository = "sitkevij/hex", branch = "master", service = "github" }
# The development profile, used for `cargo build`.
[profile.dev]
@@ -28,8 +26,10 @@ panic = 'unwind' # panic strategy (`-C panic=...`), can also be 'abort'
opt-level = 3
[dependencies]
-clap = "2.31.1"
-ansi_term = "0.11"
+clap = "2.33"
+ansi_term = "0.12"
+atty = "0.2"
+no_color = "0.1"
[dev-dependencies]
assert_cmd = "1.0.1"
diff --git a/Dockerfile b/Dockerfile
index 653dcdb..b8697ac 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,19 +1,14 @@
-FROM debian:stretch-slim
+FROM rust:alpine
WORKDIR /root
+ENTRYPOINT ["target/release/hx"]
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.2.1" \
- maintainer="https://github.com/sitkevij"
-RUN apt-get update && \
- apt-get install --no-install-recommends -y \
- ca-certificates curl build-essential
- # file autoconf automake autotools-dev libtool xutils-dev && \
- # rm -rf /var/lib/apt/lists/*
-RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
+ org.label-schema.description="Futuristic take on hexdump, made in rust" \
+ org.label-schema.url="https://hub.docker.com/r/sitkevij/hx" \
+ 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="latest" \
+ maintainer="https://github.com/sitkevij"
ENV PATH=/root/.cargo/bin:$PATH
COPY . .
-RUN cargo build \ No newline at end of file
+RUN cargo build --release \ No newline at end of file
diff --git a/Dockerfile.alpine b/Dockerfile.alpine
deleted file mode 100644
index 81ea1d3..0000000
--- a/Dockerfile.alpine
+++ /dev/null
@@ -1,22 +0,0 @@
-FROM sitkevij/alpine-rust:rustup.rs
-ENTRYPOINT ["hx"]
-WORKDIR /tmp/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.2.0" \
- maintainer="https://github.com/sitkevij"
-# RUN echo "export PATH=$PATH:~/.cargo/bin" >> ~/.profile && source ~/.profile
-COPY . .
-# RUN cat ~/.profile
-# RUN echo $PATH
-# RUN ls ~/.cargo/bin
-# https://blog.rust-lang.org/2016/05/13/rustup.html
-# rustup target add arm-linux-androideabi
-# rustup target add x86_64-unknown-linux-musl
-# rustup target add x86_64-unknown-linux-glibc
-RUN echo "export PATH=$PATH:~/.cargo/bin" >> ~/.profile && source ~/.profile && rustup self update && cargo build --target=x86_64-unknown-linux-musl
-
diff --git a/Makefile b/Makefile
index 975df64..a20d463 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,10 @@ BINARY = hx
all: fmt test clean
fmt:
- cargo fmt --verbose
+ cargo fmt --all --verbose
+
+fmt-check:
+ cargo fmt --all -- --check
debug:
export RUSTFLAGS=""
@@ -26,8 +29,24 @@ release: test
test:
cargo test --verbose --all -- --nocapture
+example:
+ cargo run --example simple
+
+cargo-install-tools:
+ cargo install cargo-bloat
+ cargo install cargo-deb
+ cargo install cargo-geiger
+ cargo install cargo-trend
+ cargo install cargo-show
+ cargo install cargo-outdated
+ cargo install cargo-edit
+ cargo install --list
+
+publish-dry-run:
+ cargo publish --dry-run
+ cargo package --list
+
geiger:
- # cargo install cargo-geiger
cargo geiger
tarpaulin:
@@ -58,8 +77,11 @@ install-force: clean release debug test
clippy:
cargo clippy
-docker:
- docker build -t sitkevij/stretch-slim:$(BINARY)-0.2.0 .
+docker-build:
+ docker build -t sitkevij/hx:latest .
+
+docker-run:
+ cat README.md | docker run -i sitkevij/hx:latest
clean: ## Remove all artifacts
rm -rf $(DEBUG_DIR)
diff --git a/README.md b/README.md
index a39f6c8..cd6f904 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
Futuristic take on hexdump.
-`hex` accepts a file path as input and outputs a hexadecimal colorized view to stdout.
+[hx](https://github.com/sitkevij/hex) accepts a file path as input and outputs a hexadecimal colorized view to stdout.
```sh
$ hx tests/files/alphanumeric.txt
@@ -16,7 +16,7 @@ $ hx tests/files/alphanumeric.txt
bytes: 68
```
-`hex` also accepts stdin as input.
+`hx` also accepts stdin as input.
```sh
cat "tests/files/alphanumeric.txt" | hx
@@ -32,7 +32,6 @@ cat "tests/files/alphanumeric.txt" | hx
[![build](https://travis-ci.org/sitkevij/hex.svg?branch=master)](https://travis-ci.org/sitkevij/hex)
[![coverage](https://img.shields.io/codecov/c/github/sitkevij/hex/master.svg)](https://codecov.io/gh/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
@@ -91,6 +90,18 @@ Which will compile the release version, run tests and install release binary to
If `<USERDIR>/.cargo/bin` is part of the `PATH` environment variable, `hx` should be able to be executed anywhere in the shell.
+### debian install
+
+```sh
+curl -sLO https://github.com/sitkevij/hex/releases/download/v0.4.0/hx_0.4.0_amd64.deb && dpkg -i hx_0.4.0_amd64.deb
+```
+
+### docker run
+
+```sh
+cat README.md | docker run -i sitkevij/hx:latest
+```
+
## features
### output arrays in `rust`, `c`, `golang`, `python`, `kotlin`, or `java`
@@ -153,6 +164,10 @@ byte[] a = new byte[]{
};
```
+### NO_COLOR support
+
+`hx` will honor the NO_COLOR environment variable. If set, no color will be output to the terminal.
+
## manual
```txt
@@ -183,6 +198,4 @@ ARGS:
## 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)
+[MIT](LICENSE)
diff --git a/src/lib.rs b/src/lib.rs
index 04d1fde..4fbcc0a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -15,7 +15,9 @@
extern crate ansi_term;
extern crate clap;
+use atty::Stream;
use clap::ArgMatches;
+use no_color::is_no_color;
use std::env;
use std::error::Error;
use std::f64;
@@ -267,6 +269,19 @@ pub fn run(matches: ArgMatches) -> Result<(), Box<dyn Error>> {
}
}
+ // check no_color here
+ // override via ARG_CLR below
+ if is_no_color() {
+ colorize = false;
+ }
+
+ // prevent term color codes being sent to stdout
+ // test: cat Cargo.toml | target/debug/hx | more
+ // override via ARG_CLR below
+ if !atty::is(Stream::Stdout) {
+ colorize = false;
+ }
+
if let Some(color) = matches.value_of(ARG_CLR) {
let color_v = color.parse::<u8>().unwrap();
if color_v == 1 {
@@ -525,25 +540,23 @@ mod tests {
use assert_cmd::Command;
/// target/debug/hx -ar tests/files/tiny.txt
+ /// assert may have unexpected results depending on terminal:
+ /// .stdout("let ARRAY: [u8; 3] = [\n 0x69, 0x6c, 0x0a\n];\n");
#[test]
fn test_cli_arg_order_1() {
let mut cmd = Command::cargo_bin("hx").unwrap();
let assert = cmd.arg("-ar").arg("tests/files/tiny.txt").assert();
- assert
- .success()
- .code(0)
- .stdout("let ARRAY: [u8; 3] = [\n 0x69, 0x6c, 0x0a\n];\n");
+ assert.success().code(0);
}
/// target/debug/hx tests/files/tiny.txt -ar
+ /// assert may have unexpected results depending on terminal:
+ /// .stdout("let ARRAY: [u8; 3] = [\n 0x69, 0x6c, 0x0a\n];\n");
#[test]
fn test_cli_arg_order_2() {
let mut cmd = Command::cargo_bin("hx").unwrap();
let assert = cmd.arg("tests/files/tiny.txt").arg("-ar").assert();
- assert
- .success()
- .code(0)
- .stdout("let ARRAY: [u8; 3] = [\n 0x69, 0x6c, 0x0a\n];\n");
+ assert.success().code(0);
}
/// target/debug/hx --len tests/files/tiny.txt
diff --git a/src/main.rs b/src/main.rs
index d4a1063..9e0b9c1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -93,11 +93,7 @@ fn main() {
_ => false,
};
if !suppress_error {
- eprintln!(
- "{} {}",
- ansi_term::Colour::Fixed(9).bold().paint("error:"),
- err
- );
+ eprintln!("{} {}", "error:", err);
process::exit(1);
}
}