Add example for enter, shells and view-source, update some docs (#4604)

This commit is contained in:
Justin Ma
2022-02-22 23:16:56 +08:00
committed by GitHub
parent c2bad71123
commit d054a724d1
12 changed files with 108 additions and 12 deletions

View File

@ -1,7 +1,7 @@
use nu_engine::{current_dir, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Value};
/// Source a file for environment variables.
#[derive(Clone)]
@ -105,4 +105,12 @@ impl Command for Enter {
Ok(PipelineData::new(call.head))
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Enter a new shell at path '../dir-foo'",
example: r#"enter ../dir-foo"#,
result: None,
}]
}
}

View File

@ -2,7 +2,7 @@ use nu_engine::current_dir;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value,
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value,
};
/// Source a file for environment variables.
@ -69,4 +69,19 @@ impl Command for Shells {
Ok(output.into_pipeline_data(None))
}
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Enter a new shell at parent path '..' and show all opened shells",
example: r#"enter ..; shells"#,
result: None,
},
Example {
description: "Show currently active shell",
example: r#"shells | where active == $true"#,
result: None,
},
]
}
}