forked from extern/nushell
Add long options for bits and bytes (#10601)
As discussed in https://github.com/nushell/nushell/pull/10597#issuecomment-1745692687
This commit is contained in:
parent
a03c1c266c
commit
471c58448e
@ -96,7 +96,7 @@ impl Command for BitsNot {
|
||||
Example {
|
||||
description:
|
||||
"Apply logical negation to a list of numbers, treat input as 2 bytes number",
|
||||
example: "[4 3 2] | bits not -n '2'",
|
||||
example: "[4 3 2] | bits not --number-bytes '2'",
|
||||
result: Some(Value::list(
|
||||
vec![
|
||||
Value::test_int(65531),
|
||||
@ -109,7 +109,7 @@ impl Command for BitsNot {
|
||||
Example {
|
||||
description:
|
||||
"Apply logical negation to a list of numbers, treat input as signed number",
|
||||
example: "[4 3 2] | bits not -s",
|
||||
example: "[4 3 2] | bits not --signed",
|
||||
result: Some(Value::list(
|
||||
vec![
|
||||
Value::test_int(-5),
|
||||
|
@ -90,7 +90,7 @@ impl Command for BitsRor {
|
||||
},
|
||||
Example {
|
||||
description: "Rotate right a list of numbers of one byte",
|
||||
example: "[15 33 92] | bits ror 2 -n '1'",
|
||||
example: "[15 33 92] | bits ror 2 --number-bytes '1'",
|
||||
result: Some(Value::list(
|
||||
vec![
|
||||
Value::test_int(195),
|
||||
|
@ -90,12 +90,12 @@ impl Command for BitsShl {
|
||||
},
|
||||
Example {
|
||||
description: "Shift left a number with 1 byte by 7 bits",
|
||||
example: "2 | bits shl 7 -n '1'",
|
||||
example: "2 | bits shl 7 --number-bytes '1'",
|
||||
result: Some(Value::test_int(0)),
|
||||
},
|
||||
Example {
|
||||
description: "Shift left a signed number by 1 bit",
|
||||
example: "0x7F | bits shl 1 -s",
|
||||
example: "0x7F | bits shl 1 --signed",
|
||||
result: Some(Value::test_int(254)),
|
||||
},
|
||||
Example {
|
||||
|
@ -97,21 +97,21 @@ impl Command for BytesAdd {
|
||||
},
|
||||
Example {
|
||||
description: "Add bytes `0x[AA BB]` to `0x[1F FF AA AA]` at index 1",
|
||||
example: "0x[1F FF AA AA] | bytes add 0x[AA BB] -i 1",
|
||||
example: "0x[1F FF AA AA] | bytes add 0x[AA BB] --index 1",
|
||||
result: Some(Value::binary(vec![0x1F, 0xAA, 0xBB, 0xFF, 0xAA, 0xAA],
|
||||
Span::test_data(),
|
||||
)),
|
||||
},
|
||||
Example {
|
||||
description: "Add bytes `0x[11]` to `0x[FF AA AA]` at the end",
|
||||
example: "0x[FF AA AA] | bytes add 0x[11] -e",
|
||||
example: "0x[FF AA AA] | bytes add 0x[11] --end",
|
||||
result: Some(Value::binary(vec![0xFF, 0xAA, 0xAA, 0x11],
|
||||
Span::test_data(),
|
||||
)),
|
||||
},
|
||||
Example {
|
||||
description: "Add bytes `0x[11 22 33]` to `0x[FF AA AA]` at the end, at index 1(the index is start from end)",
|
||||
example: "0x[FF AA BB] | bytes add 0x[11 22 33] -e -i 1",
|
||||
example: "0x[FF AA BB] | bytes add 0x[11 22 33] --end --index 1",
|
||||
result: Some(Value::binary(vec![0xFF, 0xAA, 0x11, 0x22, 0x33, 0xBB],
|
||||
Span::test_data(),
|
||||
)),
|
||||
|
@ -89,12 +89,12 @@ impl Command for BytesIndexOf {
|
||||
},
|
||||
Example {
|
||||
description: "Returns index of pattern, search from end",
|
||||
example: " 0x[33 44 55 10 01 13 44 55] | bytes index-of -e 0x[44 55]",
|
||||
example: " 0x[33 44 55 10 01 13 44 55] | bytes index-of --end 0x[44 55]",
|
||||
result: Some(Value::test_int(6)),
|
||||
},
|
||||
Example {
|
||||
description: "Returns all matched index",
|
||||
example: " 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a 0x[33 44]",
|
||||
example: " 0x[33 44 55 10 01 33 44 33 44] | bytes index-of --all 0x[33 44]",
|
||||
result: Some(Value::list(
|
||||
vec![Value::test_int(0), Value::test_int(5), Value::test_int(7)],
|
||||
Span::test_data(),
|
||||
@ -102,7 +102,7 @@ impl Command for BytesIndexOf {
|
||||
},
|
||||
Example {
|
||||
description: "Returns all matched index, searching from end",
|
||||
example: " 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a -e 0x[33 44]",
|
||||
example: " 0x[33 44 55 10 01 33 44 33 44] | bytes index-of --all --end 0x[33 44]",
|
||||
result: Some(Value::list(
|
||||
vec![Value::test_int(7), Value::test_int(5), Value::test_int(0)],
|
||||
Span::test_data(),
|
||||
|
@ -94,7 +94,7 @@ impl Command for BytesRemove {
|
||||
},
|
||||
Example {
|
||||
description: "Remove all occurrences of find binary in record field",
|
||||
example: "{ data: 0x[10 AA 10 BB 10] } | bytes remove -a 0x[10] data",
|
||||
example: "{ data: 0x[10 AA 10 BB 10] } | bytes remove --all 0x[10] data",
|
||||
result: Some(Value::test_record(Record {
|
||||
cols: vec!["data".to_string()],
|
||||
vals: vec![Value::test_binary(vec![0xAA, 0xBB])]
|
||||
@ -102,7 +102,7 @@ impl Command for BytesRemove {
|
||||
},
|
||||
Example {
|
||||
description: "Remove occurrences of find binary from end",
|
||||
example: "0x[10 AA 10 BB CC AA 10] | bytes remove -e 0x[10]",
|
||||
example: "0x[10 AA 10 BB CC AA 10] | bytes remove --end 0x[10]",
|
||||
result: Some(Value::binary (
|
||||
vec![0x10, 0xAA, 0x10, 0xBB, 0xCC, 0xAA],
|
||||
Span::test_data(),
|
||||
|
@ -94,7 +94,7 @@ impl Command for BytesReplace {
|
||||
},
|
||||
Example {
|
||||
description: "Find and replace all occurrences of find binary",
|
||||
example: "0x[10 AA 10 BB 10] | bytes replace -a 0x[10] 0x[A0]",
|
||||
example: "0x[10 AA 10 BB 10] | bytes replace --all 0x[10] 0x[A0]",
|
||||
result: Some(Value::binary (
|
||||
vec![0xA0, 0xAA, 0xA0, 0xBB, 0xA0],
|
||||
Span::test_data(),
|
||||
@ -102,7 +102,7 @@ impl Command for BytesReplace {
|
||||
},
|
||||
Example {
|
||||
description: "Find and replace all occurrences of find binary in table",
|
||||
example: "[[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes replace -a 0x[11] 0x[13] ColA ColC",
|
||||
example: "[[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes replace --all 0x[11] 0x[13] ColA ColC",
|
||||
result: Some(Value::list (
|
||||
vec![Value::test_record(Record {
|
||||
cols: vec!["ColA".to_string(), "ColB".to_string(), "ColC".to_string()],
|
||||
|
Loading…
Reference in New Issue
Block a user