add binary data handling to bits commands (#11854)

# Description
- enables `bits` commands to operate on binary data, where both inputs
are binary and can vary in length
- adds an `--endian` flag to `bits and`, `or`, `xor` for specifying
endianness (for binary values of different lengths)

# User-Facing Changes
- `bits` commands will no longer error for non-int inputs
- the default for `--number-bytes` is now `auto` (infer int size;
changed from 8)

# Tests + Formatting
> addendum: first PR, please inform if any changes are needed
This commit is contained in:
moonlander
2024-02-28 12:43:50 +00:00
committed by GitHub
parent 7b95e37bbe
commit d3895d71db
12 changed files with 742 additions and 428 deletions

View File

@ -65,7 +65,7 @@ fn bits_shift_left_negative() -> TestResult {
fn bits_shift_left_list() -> TestResult {
run_test(
"[1 2 7 32 9 10] | bits shl 3 | str join '.'",
"8.16.56.256.72.80",
"8.16.56.0.72.80",
)
}
@ -101,7 +101,7 @@ fn bits_rotate_left_negative() -> TestResult {
fn bits_rotate_left_list() -> TestResult {
run_test(
"[1 2 7 32 9 10] | bits rol 3 | str join '.'",
"8.16.56.256.72.80",
"8.16.56.1.72.80",
)
}
@ -119,6 +119,6 @@ fn bits_rotate_right_negative() -> TestResult {
fn bits_rotate_right_list() -> TestResult {
run_test(
"[1 2 7 32 23 10] | bits ror 60 | str join '.'",
"16.32.112.512.368.160",
"16.32.112.2.113.160",
)
}