summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md11
-rw-r--r--src/lib.rs2
-rw-r--r--src/main.rs4
3 files changed, 14 insertions, 3 deletions
diff --git a/README.md b/README.md
index f64dad4..42582d3 100644
--- a/README.md
+++ b/README.md
@@ -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.
@@ -164,6 +164,15 @@ 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.
diff --git a/src/lib.rs b/src/lib.rs
index 4fbcc0a..37634e3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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;
@@ -424,6 +425,7 @@ pub fn output_array(
"g" => "}",
"p" => "]",
"k" => ")",
+ "s" => "]",
_ => "unknown array format",
}
)
diff --git a/src/main.rs b/src/main.rs
index df0dd14..3fc5972 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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(