mirror of
https://github.com/nushell/nushell.git
synced 2025-05-02 17:14:27 +02:00
* typo fixes * Change signature to take in short-hand flags * update help information * Parse short-hand flags as their long counterparts * lints * Modified a couple tests to use shorthand flags
24 lines
780 B
Rust
24 lines
780 B
Rust
use nu_errors::ShellError;
|
|
use nu_plugin::Plugin;
|
|
use nu_protocol::{CallInfo, Primitive, Signature, UntaggedValue, Value};
|
|
|
|
use crate::binaryview::view_binary;
|
|
use crate::BinaryView;
|
|
|
|
impl Plugin for BinaryView {
|
|
fn config(&mut self) -> Result<Signature, ShellError> {
|
|
Ok(Signature::build("binaryview")
|
|
.desc("Autoview of binary data.")
|
|
.switch("lores", "use low resolution output mode", Some('l')))
|
|
}
|
|
|
|
fn sink(&mut self, call_info: CallInfo, input: Vec<Value>) {
|
|
for v in input {
|
|
let value_anchor = v.anchor();
|
|
if let UntaggedValue::Primitive(Primitive::Binary(b)) = &v.value {
|
|
let _ = view_binary(&b, value_anchor.as_ref(), call_info.args.has("lores"));
|
|
}
|
|
}
|
|
}
|
|
}
|