mirror of
https://github.com/nushell/nushell.git
synced 2025-04-29 23:54:26 +02:00
# Description Adds subcommands to `sys` corresponding to each column of the record returned by `sys`. This is to alleviate the fact that `sys` now returns a regular record, meaning that it must compute every column which might take a noticeable amount of time. The subcommands, on the other hand, only need to compute and return a subset of the data which should be much faster. In fact, it should be as fast as before, since this is how the lazy record worked (it would compute only each column as necessary). I choose to add subcommands instead of having an optional cell-path parameter on `sys`, since the cell-path parameter would: - increase the code complexity (can access any value at any row or nested column) - prevents discovery with tab-completion - hinders type checking and allows users to pass potentially invalid columns # User-Facing Changes Deprecates `sys` in favor of the new `sys` subcommands.
40 lines
909 B
Rust
40 lines
909 B
Rust
use nu_engine::command_prelude::*;
|
|
|
|
#[derive(Clone)]
|
|
pub struct SysMem;
|
|
|
|
impl Command for SysMem {
|
|
fn name(&self) -> &str {
|
|
"sys mem"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("sys mem")
|
|
.filter()
|
|
.category(Category::System)
|
|
.input_output_types(vec![(Type::Nothing, Type::record())])
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"View information about the system memory."
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
_engine_state: &EngineState,
|
|
_stack: &mut Stack,
|
|
call: &Call,
|
|
_input: PipelineData,
|
|
) -> Result<PipelineData, ShellError> {
|
|
Ok(super::mem(call.head).into_pipeline_data())
|
|
}
|
|
|
|
fn examples(&self) -> Vec<Example> {
|
|
vec![Example {
|
|
description: "Show info about the system memory",
|
|
example: "sys mem",
|
|
result: None,
|
|
}]
|
|
}
|
|
}
|