mirror of
https://github.com/nushell/nushell.git
synced 2024-12-16 20:21:09 +01:00
Wire hex viewing into a few more places (#572)
This commit is contained in:
parent
3522bead97
commit
1efae6876d
@ -97,15 +97,19 @@ fn into_binary(
|
|||||||
let head = call.head;
|
let head = call.head;
|
||||||
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
|
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
|
||||||
|
|
||||||
input.map(
|
match input {
|
||||||
|
PipelineData::ByteStream(..) => Ok(input),
|
||||||
|
_ => input.map(
|
||||||
move |v| {
|
move |v| {
|
||||||
if column_paths.is_empty() {
|
if column_paths.is_empty() {
|
||||||
action(&v, head)
|
action(&v, head)
|
||||||
} else {
|
} else {
|
||||||
let mut ret = v;
|
let mut ret = v;
|
||||||
for path in &column_paths {
|
for path in &column_paths {
|
||||||
let r =
|
let r = ret.update_cell_path(
|
||||||
ret.update_cell_path(&path.members, Box::new(move |old| action(old, head)));
|
&path.members,
|
||||||
|
Box::new(move |old| action(old, head)),
|
||||||
|
);
|
||||||
if let Err(error) = r {
|
if let Err(error) = r {
|
||||||
return Value::Error { error };
|
return Value::Error { error };
|
||||||
}
|
}
|
||||||
@ -115,7 +119,8 @@ fn into_binary(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
engine_state.ctrlc.clone(),
|
engine_state.ctrlc.clone(),
|
||||||
)
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn int_to_endian(n: i64) -> Vec<u8> {
|
fn int_to_endian(n: i64) -> Vec<u8> {
|
||||||
|
@ -75,6 +75,19 @@ impl Command for Table {
|
|||||||
head,
|
head,
|
||||||
None,
|
None,
|
||||||
)),
|
)),
|
||||||
|
PipelineData::Value(Value::Binary { val, .. }, ..) => Ok(PipelineData::StringStream(
|
||||||
|
StringStream::from_stream(
|
||||||
|
vec![Ok(if val.iter().all(|x| x.is_ascii()) {
|
||||||
|
format!("{}", String::from_utf8_lossy(&val))
|
||||||
|
} else {
|
||||||
|
format!("{}\n", nu_pretty_hex::pretty_hex(&val))
|
||||||
|
})]
|
||||||
|
.into_iter(),
|
||||||
|
ctrlc,
|
||||||
|
),
|
||||||
|
head,
|
||||||
|
None,
|
||||||
|
)),
|
||||||
PipelineData::Value(Value::List { vals, .. }, ..) => {
|
PipelineData::Value(Value::List { vals, .. }, ..) => {
|
||||||
let table = convert_to_table(row_offset, &vals, ctrlc, &config, call.head)?;
|
let table = convert_to_table(row_offset, &vals, ctrlc, &config, call.head)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user