mirror of
https://github.com/nushell/nushell.git
synced 2025-04-29 07:34:28 +02:00
# Description Changes `get_full_help` to take a `&dyn Command` instead of multiple arguments (`&Signature`, `&Examples` `is_parser_keyword`). All of these arguments can be gathered from a `Command`, so there is no need to pass the pieces to `get_full_help`. This PR also fixes an issue where the search terms are not shown if `--help` is used on a command.
35 lines
947 B
Rust
35 lines
947 B
Rust
use nu_engine::{command_prelude::*, get_full_help};
|
|
|
|
#[derive(Clone)]
|
|
pub struct MathCommand;
|
|
|
|
impl Command for MathCommand {
|
|
fn name(&self) -> &str {
|
|
"math"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("math")
|
|
.category(Category::Math)
|
|
.input_output_types(vec![(Type::Nothing, Type::String)])
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Use mathematical functions as aggregate functions on a list of numbers or tables."
|
|
}
|
|
|
|
fn extra_usage(&self) -> &str {
|
|
"You must use one of the following subcommands. Using this command as-is will only produce this help message."
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
engine_state: &EngineState,
|
|
stack: &mut Stack,
|
|
call: &Call,
|
|
_input: PipelineData,
|
|
) -> Result<PipelineData, ShellError> {
|
|
Ok(Value::string(get_full_help(self, engine_state, stack), call.head).into_pipeline_data())
|
|
}
|
|
}
|