forked from extern/nushell
Merge master
This commit is contained in:
@ -10,8 +10,7 @@ impl WholeStreamCommand for CD {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("cd")
|
||||
.optional("directory", SyntaxType::Path)
|
||||
Signature::build("cd").optional("directory", SyntaxType::Path)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::{Dictionary, Value};
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
use chrono::{DateTime, Local, Utc};
|
||||
|
||||
|
@ -11,8 +11,7 @@ impl WholeStreamCommand for Exit {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("exit")
|
||||
.switch("now")
|
||||
Signature::build("exit").switch("now")
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -16,8 +16,7 @@ impl WholeStreamCommand for First {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("first")
|
||||
.required("amount", SyntaxType::Literal)
|
||||
Signature::build("first").required("amount", SyntaxType::Literal)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -1,12 +1,13 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::Value;
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Get;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct GetArgs {
|
||||
member: Tagged<String>,
|
||||
rest: Vec<Tagged<String>>,
|
||||
}
|
||||
|
||||
@ -16,7 +17,9 @@ impl WholeStreamCommand for Get {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("get").rest(SyntaxType::Member)
|
||||
Signature::build("get")
|
||||
.required("member", SyntaxType::Member)
|
||||
.rest(SyntaxType::Member)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
@ -63,13 +66,24 @@ fn get_member(path: &Tagged<String>, obj: &Tagged<Value>) -> Result<Tagged<Value
|
||||
}
|
||||
|
||||
pub fn get(
|
||||
GetArgs { rest: fields }: GetArgs,
|
||||
GetArgs {
|
||||
member,
|
||||
rest: fields,
|
||||
}: GetArgs,
|
||||
RunnableContext { input, .. }: RunnableContext,
|
||||
) -> Result<OutputStream, ShellError> {
|
||||
let stream = input
|
||||
.values
|
||||
.map(move |item| {
|
||||
let mut result = VecDeque::new();
|
||||
|
||||
let member = vec![member.clone()];
|
||||
|
||||
let fields = vec![&member, &fields]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect::<Vec<&Tagged<String>>>();
|
||||
|
||||
for field in &fields {
|
||||
match get_member(field, &item) {
|
||||
Ok(Tagged {
|
||||
|
@ -101,20 +101,6 @@ impl PerItemCommand for Help {
|
||||
}
|
||||
}
|
||||
|
||||
// pub struct Signature {
|
||||
// pub name: String,
|
||||
// #[new(default)]
|
||||
// pub usage: String,
|
||||
// #[new(default)]
|
||||
// pub positional: Vec<PositionalType>,
|
||||
// #[new(value = "None")]
|
||||
// pub rest_positional: Option<SyntaxType>,
|
||||
// #[new(default)]
|
||||
// pub named: IndexMap<String, NamedType>,
|
||||
// #[new(value = "false")]
|
||||
// pub is_filter: bool,
|
||||
// }
|
||||
|
||||
help.push_back(ReturnSuccess::value(
|
||||
Value::string(long_desc).tagged(tag.clone()),
|
||||
));
|
||||
@ -125,9 +111,11 @@ impl PerItemCommand for Help {
|
||||
}
|
||||
_ => {
|
||||
let msg = r#"Welcome to Nushell.
|
||||
|
||||
Here are some tips to help you get started.
|
||||
* help commands - list all available commands
|
||||
* help <command name> - display help about a particular command
|
||||
* help commands - list all available commands
|
||||
* help <command name> - display help about a particular command
|
||||
|
||||
You can also learn more at http://book.nushell.sh"#;
|
||||
|
||||
let mut output_stream = VecDeque::new();
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::{Primitive, Value};
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
use log::trace;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::context::CommandRegistry;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::base::select_fields;
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::base::reject_fields;
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::TaggedDictBuilder;
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Shells;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::{TaggedDictBuilder, Value};
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Size;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::{Primitive, TaggedDictBuilder, Value};
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
use log::trace;
|
||||
|
||||
@ -40,7 +40,11 @@ impl WholeStreamCommand for SplitColumn {
|
||||
}
|
||||
|
||||
fn split_column(
|
||||
SplitColumnArgs { separator, rest, collapse_empty}: SplitColumnArgs,
|
||||
SplitColumnArgs {
|
||||
separator,
|
||||
rest,
|
||||
collapse_empty,
|
||||
}: SplitColumnArgs,
|
||||
RunnableContext { input, name, .. }: RunnableContext,
|
||||
) -> Result<OutputStream, ShellError> {
|
||||
Ok(input
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::{Primitive, Value};
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
use log::trace;
|
||||
|
||||
@ -17,8 +17,7 @@ impl WholeStreamCommand for SplitRow {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("split-row")
|
||||
.required("separator", SyntaxType::Any)
|
||||
Signature::build("split-row").required("separator", SyntaxType::Any)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::{TaggedDictBuilder, Value};
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Tags;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::Value;
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Trim;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::commands::WholeStreamCommand;
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::{Dictionary, Value};
|
||||
use crate::errors::ShellError;
|
||||
use crate::parser::registry::Signature;
|
||||
use crate::prelude::*;
|
||||
use indexmap::IndexMap;
|
||||
|
@ -12,8 +12,7 @@ impl PerItemCommand for Where {
|
||||
}
|
||||
|
||||
fn signature(&self) -> registry::Signature {
|
||||
Signature::build("where")
|
||||
.required("condition", SyntaxType::Block)
|
||||
Signature::build("where").required("condition", SyntaxType::Block)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
@ -43,9 +42,7 @@ impl PerItemCommand for Where {
|
||||
VecDeque::new()
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(e)
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
Tagged { tag, .. } => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::errors::ShellError;
|
||||
use crate::data::Value;
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
|
||||
use crate::commands::WholeStreamCommand;
|
||||
@ -13,8 +13,7 @@ impl WholeStreamCommand for Which {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("which")
|
||||
.required("name", SyntaxType::Any)
|
||||
Signature::build("which").required("name", SyntaxType::Any)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
Reference in New Issue
Block a user