simple contains arguments (#3874)

This commit is contained in:
Fernando Herrera 2021-07-31 15:01:05 +01:00 committed by GitHub
parent 762e528ec5
commit 5826126284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,11 +20,10 @@ impl WholeStreamCommand for DataFrame {
} }
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("dataframe contains").required_named( Signature::build("dataframe contains").required(
"pattern", "pattern",
SyntaxShape::String, SyntaxShape::String,
"Regex pattern to be searched", "Regex pattern to be searched",
Some('p'),
) )
} }
@ -35,7 +34,7 @@ impl WholeStreamCommand for DataFrame {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns boolean indicating if patter was found", description: "Returns boolean indicating if patter was found",
example: "[abc acb acb] | dataframe to-df | dataframe contains -p ab", example: "[abc acb acb] | dataframe to-df | dataframe contains ab",
result: Some(vec![NuDataFrame::try_from_columns( result: Some(vec![NuDataFrame::try_from_columns(
vec![Column::new( vec![Column::new(
"0".to_string(), "0".to_string(),
@ -55,7 +54,7 @@ impl WholeStreamCommand for DataFrame {
fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> { fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
let tag = args.call_info.name_tag.clone(); let tag = args.call_info.name_tag.clone();
let pattern: Tagged<String> = args.req_named("pattern")?; let pattern: Tagged<String> = args.req(0)?;
let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?; let (df, df_tag) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?;