Skip to content

Commit

Permalink
Merge pull request #55 from sitkevij/develop
Browse files Browse the repository at this point in the history
0.4.1 develop
  • Loading branch information
sitkevij authored Feb 23, 2021
2 parents b0a844a + 2bba305 commit 959f88d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- develop
- main
- master
schedule:
- cron: "0 9 * * *"

env:
RUST_BACKTRACE: full
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include = ["src/**/*","Cargo.toml","Cargo.lock", "README.md"]
license = "MIT"
name = "hx"
readme ="README.md"
version = "0.4.0"
version = "0.4.1"
edition = "2018"

# see https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ docker-build:
docker-run:
cat README.md | docker run -i sitkevij/hx:latest

deb:
cargo deb

clean: ## Remove all artifacts
rm -rf $(DEBUG_DIR)
rm -rf $(RELEASE_DIR)
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ hx tests/files/alphanumeric.txt
bytes: 68
```

`hx` also accepts stdin as input.
[hx](https://github.com/sitkevij/hex) also accepts stdin as input.

```sh
cat "tests/files/alphanumeric.txt" | hx
Expand Down Expand Up @@ -93,7 +93,7 @@ If `<USERDIR>/.cargo/bin` is part of the `PATH` environment variable, `hx` shoul
### 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
curl -sLO https://github.com/sitkevij/hex/releases/download/v0.4.1/hx_0.4.1_amd64.deb && dpkg -i hx_0.4.1_amd64.deb
```

### docker run
Expand All @@ -104,7 +104,7 @@ cat README.md | docker run -i sitkevij/hx:latest

## features

### output arrays in `rust`, `c`, `golang`, `python`, `kotlin`, or `java`
### output arrays in `rust`, `c`, `golang`, `python`, `kotlin`, `java`, or `swift`

`hx` has a feature which can output the input file bytes as source code arrays.

Expand Down Expand Up @@ -164,10 +164,24 @@ byte[] a = new byte[]{
};
```

#### swift array: -as

```sh
$ hx -as -c8 tests/files/tiny.txt
let a: [UInt8] = [
0x69, 0x6c, 0x0a
]
```

### NO_COLOR support

`hx` will honor the NO_COLOR environment variable. If set, no color will be output to the terminal.

Rust `no_color` crate:

* <https://crates.io/crates/no_color>
* <https://github.com/sitkevij/no_color>

## manual

```txt
Expand Down Expand Up @@ -198,4 +212,4 @@ ARGS:

## license

[MIT](LICENSE)
MIT
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ pub fn output_array(
"p" => writeln!(locked, "a = [")?,
"k" => writeln!(locked, "val a = byteArrayOf(")?,
"j" => writeln!(locked, "byte[] a = new byte[]{{")?,
"s" => writeln!(locked, "let a: [UInt8] = [")?,
_ => writeln!(locked, "unknown array format")?,
}
let mut i: u64 = 0x0;
Expand All @@ -424,6 +425,7 @@ pub fn output_array(
"g" => "}",
"p" => "]",
"k" => ")",
"s" => "]",
_ => "unknown array format",
}
)
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ fn main() {
.short("a")
.long(ARG_ARR)
.value_name("array_format")
.help("Set source code format output: rust (r), C (c), golang (g), python (p), kotlin (k), java (j)")
.possible_values(&["r", "c", "g", "p", "k", "j"])
.help("Set source code format output: rust (r), C (c), golang (g), python (p), kotlin (k), java (j), swift (s)")
.possible_values(&["r", "c", "g", "p", "k", "j", "s"])
.takes_value(true),
)
.arg(
Expand Down Expand Up @@ -93,7 +93,7 @@ fn main() {
_ => false,
};
if !suppress_error {
eprintln!("{} {}", "error:", err);
eprintln!("error: {}", err);
process::exit(1);
}
}
Expand Down

0 comments on commit 959f88d

Please sign in to comment.