mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
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)",
|
||||
"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)",
|
||||
"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)",
|
||||
"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)",
|
||||
@ -2394,11 +2393,6 @@ dependencies = [
|
||||
"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]]
|
||||
name = "result"
|
||||
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 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 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 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"
|
||||
|
13
Cargo.toml
13
Cargo.toml
@ -67,7 +67,6 @@ regex = "1.1.8"
|
||||
pretty-hex = "0.1.0"
|
||||
neso = "0.5.0"
|
||||
rawkey = { git = "https://github.com/jonathandturner/rawkey.git" }
|
||||
resize = "0.3.0"
|
||||
crossterm = "0.9.6"
|
||||
tempfile = "3.1.0"
|
||||
image = "0.21.2"
|
||||
@ -79,21 +78,17 @@ pretty_assertions = "0.6.1"
|
||||
name = "nu"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_sum"
|
||||
path = "src/plugins/sum.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_inc"
|
||||
path = "src/plugins/inc.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_newskip"
|
||||
path = "src/plugins/newskip.rs"
|
||||
name = "nu_plugin_skip"
|
||||
path = "src/plugins/skip.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_treeview"
|
||||
path = "src/plugins/treeview.rs"
|
||||
name = "nu_plugin_tree"
|
||||
path = "src/plugins/tree.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "nu_plugin_binaryview"
|
||||
|
@ -159,7 +159,6 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
||||
command("sysinfo", Box::new(sysinfo::sysinfo)),
|
||||
command("cd", Box::new(cd::cd)),
|
||||
command("view", Box::new(view::view)),
|
||||
command("skip", Box::new(skip::skip)),
|
||||
command("first", Box::new(first::first)),
|
||||
command("size", Box::new(size::size)),
|
||||
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("save", Box::new(save::save)),
|
||||
sink("table", Box::new(table::table)),
|
||||
sink("tree", Box::new(tree::tree)),
|
||||
sink("vtable", Box::new(vtable::vtable)),
|
||||
]);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ crate mod ps;
|
||||
crate mod reject;
|
||||
crate mod save;
|
||||
crate mod size;
|
||||
crate mod skip;
|
||||
crate mod skip_while;
|
||||
crate mod sort_by;
|
||||
crate mod split_column;
|
||||
@ -33,7 +32,6 @@ crate mod table;
|
||||
crate mod to_array;
|
||||
crate mod to_json;
|
||||
crate mod to_toml;
|
||||
crate mod tree;
|
||||
crate mod trim;
|
||||
crate mod view;
|
||||
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 {
|
||||
fn config(&mut self) -> Result<CommandConfig, ShellError> {
|
||||
Ok(CommandConfig {
|
||||
name: "treeview".to_string(),
|
||||
name: "tree".to_string(),
|
||||
mandatory_positional: vec![],
|
||||
optional_positional: vec![],
|
||||
can_load: vec![],
|
Loading…
Reference in New Issue
Block a user