forked from extern/nushell
Finish moving a couple commands to plugins, remove unused plugin
This commit is contained in:
parent
8c09337c04
commit
958bb534b4
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -1668,7 +1668,6 @@ dependencies = [
|
|||||||
"rawkey 0.1.0 (git+https://github.com/jonathandturner/rawkey.git)",
|
"rawkey 0.1.0 (git+https://github.com/jonathandturner/rawkey.git)",
|
||||||
"regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"resize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustyline 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -2394,11 +2393,6 @@ dependencies = [
|
|||||||
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "resize"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "result"
|
name = "result"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@ -3614,7 +3608,6 @@ dependencies = [
|
|||||||
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
|
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
|
||||||
"checksum render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "68ed587df09cfb7ce1bc6fe8f77e24db219f222c049326ccbfb948ec67e31664"
|
"checksum render-tree 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "68ed587df09cfb7ce1bc6fe8f77e24db219f222c049326ccbfb948ec67e31664"
|
||||||
"checksum reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)" = "00eb63f212df0e358b427f0f40aa13aaea010b470be642ad422bcbca2feff2e4"
|
"checksum reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)" = "00eb63f212df0e358b427f0f40aa13aaea010b470be642ad422bcbca2feff2e4"
|
||||||
"checksum resize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ed16788c219e719ec11912d96f4e819641941578d1b02f00dab139b00789fb8"
|
|
||||||
"checksum result 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "194d8e591e405d1eecf28819740abed6d719d1a2db87fc0bcdedee9a26d55560"
|
"checksum result 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "194d8e591e405d1eecf28819740abed6d719d1a2db87fc0bcdedee9a26d55560"
|
||||||
"checksum roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "330d8f80a274bc3cb608908ee345970e7e24b96907f1ad69615a498bec57871c"
|
"checksum roxmltree 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "330d8f80a274bc3cb608908ee345970e7e24b96907f1ad69615a498bec57871c"
|
||||||
"checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2"
|
"checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2"
|
||||||
|
13
Cargo.toml
13
Cargo.toml
@ -67,7 +67,6 @@ regex = "1.1.8"
|
|||||||
pretty-hex = "0.1.0"
|
pretty-hex = "0.1.0"
|
||||||
neso = "0.5.0"
|
neso = "0.5.0"
|
||||||
rawkey = { git = "https://github.com/jonathandturner/rawkey.git" }
|
rawkey = { git = "https://github.com/jonathandturner/rawkey.git" }
|
||||||
resize = "0.3.0"
|
|
||||||
crossterm = "0.9.6"
|
crossterm = "0.9.6"
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
image = "0.21.2"
|
image = "0.21.2"
|
||||||
@ -79,21 +78,17 @@ pretty_assertions = "0.6.1"
|
|||||||
name = "nu"
|
name = "nu"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "nu_plugin_sum"
|
|
||||||
path = "src/plugins/sum.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "nu_plugin_inc"
|
name = "nu_plugin_inc"
|
||||||
path = "src/plugins/inc.rs"
|
path = "src/plugins/inc.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "nu_plugin_newskip"
|
name = "nu_plugin_skip"
|
||||||
path = "src/plugins/newskip.rs"
|
path = "src/plugins/skip.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "nu_plugin_treeview"
|
name = "nu_plugin_tree"
|
||||||
path = "src/plugins/treeview.rs"
|
path = "src/plugins/tree.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "nu_plugin_binaryview"
|
name = "nu_plugin_binaryview"
|
||||||
|
@ -159,7 +159,6 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
|||||||
command("sysinfo", Box::new(sysinfo::sysinfo)),
|
command("sysinfo", Box::new(sysinfo::sysinfo)),
|
||||||
command("cd", Box::new(cd::cd)),
|
command("cd", Box::new(cd::cd)),
|
||||||
command("view", Box::new(view::view)),
|
command("view", Box::new(view::view)),
|
||||||
command("skip", Box::new(skip::skip)),
|
|
||||||
command("first", Box::new(first::first)),
|
command("first", Box::new(first::first)),
|
||||||
command("size", Box::new(size::size)),
|
command("size", Box::new(size::size)),
|
||||||
command("from-ini", Box::new(from_ini::from_ini)),
|
command("from-ini", Box::new(from_ini::from_ini)),
|
||||||
@ -193,7 +192,6 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
|||||||
sink("clip", Box::new(clip::clip)),
|
sink("clip", Box::new(clip::clip)),
|
||||||
sink("save", Box::new(save::save)),
|
sink("save", Box::new(save::save)),
|
||||||
sink("table", Box::new(table::table)),
|
sink("table", Box::new(table::table)),
|
||||||
sink("tree", Box::new(tree::tree)),
|
|
||||||
sink("vtable", Box::new(vtable::vtable)),
|
sink("vtable", Box::new(vtable::vtable)),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ crate mod ps;
|
|||||||
crate mod reject;
|
crate mod reject;
|
||||||
crate mod save;
|
crate mod save;
|
||||||
crate mod size;
|
crate mod size;
|
||||||
crate mod skip;
|
|
||||||
crate mod skip_while;
|
crate mod skip_while;
|
||||||
crate mod sort_by;
|
crate mod sort_by;
|
||||||
crate mod split_column;
|
crate mod split_column;
|
||||||
@ -33,7 +32,6 @@ crate mod table;
|
|||||||
crate mod to_array;
|
crate mod to_array;
|
||||||
crate mod to_json;
|
crate mod to_json;
|
||||||
crate mod to_toml;
|
crate mod to_toml;
|
||||||
crate mod tree;
|
|
||||||
crate mod trim;
|
crate mod trim;
|
||||||
crate mod view;
|
crate mod view;
|
||||||
crate mod vtable;
|
crate mod vtable;
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
use crate::errors::ShellError;
|
|
||||||
use crate::prelude::*;
|
|
||||||
|
|
||||||
pub fn skip(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|
||||||
if args.len() == 0 {
|
|
||||||
return Err(ShellError::maybe_labeled_error(
|
|
||||||
"Skip requires an amount",
|
|
||||||
"needs parameter",
|
|
||||||
args.name_span,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let amount = args.expect_nth(0)?.as_i64();
|
|
||||||
|
|
||||||
let amount = match amount {
|
|
||||||
Ok(o) => o,
|
|
||||||
Err(_) => {
|
|
||||||
return Err(ShellError::labeled_error(
|
|
||||||
"Value is not a number",
|
|
||||||
"expected integer",
|
|
||||||
args.expect_nth(0)?.span,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let input = args.input;
|
|
||||||
|
|
||||||
Ok(input
|
|
||||||
.skip(amount as u64)
|
|
||||||
.map(|v| ReturnValue::Value(v))
|
|
||||||
.boxed())
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
use crate::commands::command::SinkCommandArgs;
|
|
||||||
use crate::errors::ShellError;
|
|
||||||
use crate::format::TreeView;
|
|
||||||
use crate::prelude::*;
|
|
||||||
|
|
||||||
pub fn tree(args: SinkCommandArgs) -> Result<(), ShellError> {
|
|
||||||
if args.input.len() > 0 {
|
|
||||||
let mut host = args.ctx.host.lock().unwrap();
|
|
||||||
for i in args.input.iter() {
|
|
||||||
let view = TreeView::from_value(&i);
|
|
||||||
handle_unexpected(&mut *host, |host| crate::format::print_view(&view, host));
|
|
||||||
host.stdout("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
use indexmap::IndexMap;
|
|
||||||
use nu::{serve_plugin, Args, CommandConfig, Plugin, Primitive, ShellError, Value};
|
|
||||||
|
|
||||||
struct Sum;
|
|
||||||
|
|
||||||
impl Sum {
|
|
||||||
fn new() -> Sum {
|
|
||||||
Sum
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Plugin for Sum {
|
|
||||||
fn config(&mut self) -> Result<CommandConfig, ShellError> {
|
|
||||||
Ok(CommandConfig {
|
|
||||||
name: "sum".to_string(),
|
|
||||||
mandatory_positional: vec![],
|
|
||||||
optional_positional: vec![],
|
|
||||||
can_load: vec![],
|
|
||||||
can_save: vec![],
|
|
||||||
is_filter: false,
|
|
||||||
is_sink: true,
|
|
||||||
named: IndexMap::new(),
|
|
||||||
rest_positional: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sink(&mut self, _args: Args, input: Vec<Value>) {
|
|
||||||
let mut total = 0i64;
|
|
||||||
|
|
||||||
for v in input {
|
|
||||||
match v {
|
|
||||||
Value::Primitive(Primitive::Int(i)) => {
|
|
||||||
total += i;
|
|
||||||
}
|
|
||||||
Value::Primitive(Primitive::Bytes(i)) => {
|
|
||||||
total += i as i64;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("Result: {}", total);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
serve_plugin(&mut Sum::new());
|
|
||||||
}
|
|
@ -84,7 +84,7 @@ struct TreeViewer;
|
|||||||
impl Plugin for TreeViewer {
|
impl Plugin for TreeViewer {
|
||||||
fn config(&mut self) -> Result<CommandConfig, ShellError> {
|
fn config(&mut self) -> Result<CommandConfig, ShellError> {
|
||||||
Ok(CommandConfig {
|
Ok(CommandConfig {
|
||||||
name: "treeview".to_string(),
|
name: "tree".to_string(),
|
||||||
mandatory_positional: vec![],
|
mandatory_positional: vec![],
|
||||||
optional_positional: vec![],
|
optional_positional: vec![],
|
||||||
can_load: vec![],
|
can_load: vec![],
|
Loading…
Reference in New Issue
Block a user