diff options
author | sitkevij <1553398+sitkevij@users.noreply.github.com> | 2023-09-24 20:46:28 -0700 |
---|---|---|
committer | sitkevij <1553398+sitkevij@users.noreply.github.com> | 2023-09-24 20:46:28 -0700 |
commit | fcbe0653d9e5eb1b6e28ffb840c6a05dc8655c59 (patch) | |
tree | b854d2b078e1a4cc1a5249610a313706eea90843 | |
parent | c7b544f66aa67b789b563a457459fc29d9d872a4 (diff) |
docs: update readme, add manual in markdown format, add makefile for manual generation, add lorem test file
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 18 | ||||
-rw-r--r-- | MANPAGE.md | 84 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | hx.1 | 76 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | tests/files/lorem.md | 3 |
7 files changed, 186 insertions, 10 deletions
@@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ansi_term" version = "0.11.0" @@ -1,13 +1,13 @@ [package] authors = ["sitkevij"] -categories = ["command-line-utilities","development-tools"] +categories = ["command-line-utilities", "development-tools"] description = "Futuristic take on hexdump, made in Rust." repository = "https://github.com/sitkevij/hex" keywords = ["hexdump", "hexadecimal", "tools", "ascii", "hex"] -include = ["src/**/*","Cargo.toml","Cargo.lock", "README.md"] +include = ["src/**/*", "Cargo.toml", "Cargo.lock", "README.md", "hx.1"] license = "MIT" name = "hx" -readme ="README.md" +readme = "README.md" version = "0.4.2" edition = "2018" @@ -15,12 +15,12 @@ edition = "2018" # The development profile, used for `cargo build`. [profile.dev] -opt-level = 0 # controls the `--opt-level` the compiler builds with. - # 0-1 is good for debugging. 2 is well-optimized. Max is 3. -codegen-units = 16 # if > 1 enables parallel code generation which improves - # compile times, but prevents some optimizations. - # Passes `-C codegen-units`. Ignored when `lto = true`. -panic = 'unwind' # panic strategy (`-C panic=...`), can also be 'abort' +opt-level = 0 # controls the `--opt-level` the compiler builds with. +# 0-1 is good for debugging. 2 is well-optimized. Max is 3. +codegen-units = 16 # if > 1 enables parallel code generation which improves +# compile times, but prevents some optimizations. +# Passes `-C codegen-units`. Ignored when `lto = true`. +panic = 'unwind' # panic strategy (`-C panic=...`), can also be 'abort' [profile.release] opt-level = 3 diff --git a/MANPAGE.md b/MANPAGE.md new file mode 100644 index 0000000..16f1bd9 --- /dev/null +++ b/MANPAGE.md @@ -0,0 +1,84 @@ +# NAME + +**hx** - Futuristic take on hexdump, made in Rust. + +# SYNOPSIS + +```txt +hx [-tcfl][--color=0,1][--cols 0-9][--format oxXb] inputfile +hx [-a rcgpkjsf][ --array=rcgpkjsf] inputfile +hx [-up][--func 0-9][--places 0-9] +hx [-hV] +``` + +# OPTIONS + +```txt +USAGE: + hx [OPTIONS] [INPUTFILE] + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +OPTIONS: + -a, --array <array_format> Set source code format output: rust (r), C (c), golang (g), python (p), kotlin (k), + java (j), swift (s), fsharp (f) [possible values: r, c, g, p, k, j, s, f] + -t, --color <color> Set color tint terminal output. 0 to disable, 1 to enable [possible values: 0, 1] + -c, --cols <columns> Set column length + -f, --format <format> Set format of octet: Octal (o), LowerHex (x), UpperHex (X), Binary (b) [possible + values: o, x, X, b] + -u, --func <func_length> Set function wave length + -l, --len <len> Set <len> bytes to read + -p, --places <func_places> Set function wave output decimal places + +ARGS: + <INPUTFILE> Pass file path as an argument, or input data may be passed via stdin + +``` + +# DESCRIPTION + +**hx** outputs a hexadecimal representation of input. + +Defaults to colorized output, with option to disable color via -t [0,1] parameter. + +The **NO_COLOR** environment variable is honored if set. + +# EXIT STATUS + +**hx** exits 0 on success, and >0 if an error occurs. + +# EXAMPLES + +**hx** with file path as input, outputting colorized hexadecimal. + +```sh +$ hx tests/files/alphanumeric.txt +0x000000: 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6a abcdefghij +0x00000a: 0x6b 0x69 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 kilmnopqrs +0x000014: 0x74 0x75 0x76 0x77 0x78 0x79 0x7a 0x30 0x31 0x32 tuvwxyz012 +0x00001e: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x0a 0x30 0x31 3456789.01 +0x000028: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x000032: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x00003c: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 23456789 + bytes: 68 +``` + +**hx** with stdin as input, outputting colorized hexadecimal. + +```sh +$ cat "tests/files/alphanumeric.txt" | hx +0x000000: 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6a abcdefghij +0x00000a: 0x6b 0x69 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 kilmnopqrs +0x000014: 0x74 0x75 0x76 0x77 0x78 0x79 0x7a 0x30 0x31 0x32 tuvwxyz012 +0x00001e: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x0a 0x30 0x31 3456789.01 +0x000028: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x000032: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x00003c: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 23456789 + bytes: 68 +``` + +# SEE ALSO + +cat(1), echo(1), more(1), less(1), head(1), tail(1), hexdump(1) @@ -89,6 +89,17 @@ docker-run: deb: cargo deb +manpage: + target/debug/hx --help >target/debug/hx.1.txt + pandoc MANPAGE.md -s -t man + HELP=$(cat target/debug/hx.1.txt) + echo "$HELP" + MANPAGE=$(cat MANPAGE.md) + # echo $MANPAGE | sed 's/$/\\n/g' | tr -d'\n' + pandoc --standalone --to man MANPAGE.md -o hx.1 + cp hx.1 /usr/local/share/man/man1 + man hx + clean: ## Remove all artifacts rm -rf $(DEBUG_DIR) rm -rf $(RELEASE_DIR) @@ -0,0 +1,76 @@ +.\" Automatically generated by Pandoc 3.1.8 +.\" +.TH "" "" "" "" "" +.SH NAME +\f[B]hx\f[R] - Futuristic take on hexdump, made in Rust. +.SH SYNOPSIS +.IP +.EX +hx [-tcfl][--color=0,1][--cols 0-9][--format oxXb] inputfile +hx [-a rcgpkjsf][ --array=rcgpkjsf] inputfile +hx [-up][--func 0-9][--places 0-9] +hx [-hV] +.EE +.SH OPTIONS +.IP +.EX +USAGE: + hx [OPTIONS] [INPUTFILE] + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +OPTIONS: + -a, --array <array_format> Set source code format output: rust (r), C (c), golang (g), python (p), kotlin (k), + java (j), swift (s), fsharp (f) [possible values: r, c, g, p, k, j, s, f] + -t, --color <color> Set color tint terminal output. 0 to disable, 1 to enable [possible values: 0, 1] + -c, --cols <columns> Set column length + -f, --format <format> Set format of octet: Octal (o), LowerHex (x), UpperHex (X), Binary (b) [possible + values: o, x, X, b] + -u, --func <func_length> Set function wave length + -l, --len <len> Set <len> bytes to read + -p, --places <func_places> Set function wave output decimal places + +ARGS: + <INPUTFILE> Pass file path as an argument, or input data may be passed via stdin +.EE +.SH DESCRIPTION +\f[B]hx\f[R] outputs a hexadecimal representation of input. +.PP +Defaults to colorized output, with option to disable color via -t [0,1] +parameter. +.PP +The \f[B]NO_COLOR\f[R] environment variable is honored if set. +.SH EXIT STATUS +\f[B]hx\f[R] exits\ 0 on success, and\ >0 if an error occurs. +.SH EXAMPLES +\f[B]hx\f[R] with file path as input, outputting colorized hexadecimal. +.IP +.EX +$ hx tests/files/alphanumeric.txt +0x000000: 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6a abcdefghij +0x00000a: 0x6b 0x69 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 kilmnopqrs +0x000014: 0x74 0x75 0x76 0x77 0x78 0x79 0x7a 0x30 0x31 0x32 tuvwxyz012 +0x00001e: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x0a 0x30 0x31 3456789.01 +0x000028: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x000032: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x00003c: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 23456789 + bytes: 68 +.EE +.PP +\f[B]hx\f[R] with stdin as input, outputting colorized hexadecimal. +.IP +.EX +$ cat \[dq]tests/files/alphanumeric.txt\[dq] | hx +0x000000: 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6a abcdefghij +0x00000a: 0x6b 0x69 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 kilmnopqrs +0x000014: 0x74 0x75 0x76 0x77 0x78 0x79 0x7a 0x30 0x31 0x32 tuvwxyz012 +0x00001e: 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x0a 0x30 0x31 3456789.01 +0x000028: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x000032: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x31 2345678901 +0x00003c: 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 23456789 + bytes: 68 +.EE +.SH SEE ALSO +cat(1), echo(1), more(1), less(1), head(1), tail(1), hexdump(1) diff --git a/src/main.rs b/src/main.rs index 176732b..2021fc5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,7 @@ fn main() { ) .arg( Arg::with_name(hx::ARG_INP) - .help("Pass file path as an argument for hex dump") + .help("Pass file path as an argument, or input data may be passed via stdin") .required(false) .index(1), ) diff --git a/tests/files/lorem.md b/tests/files/lorem.md new file mode 100644 index 0000000..69f6d93 --- /dev/null +++ b/tests/files/lorem.md @@ -0,0 +1,3 @@ +# Lorem Ipsum + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |