nu_cmd_lang/core_commands/scope/
engine_stats.rs

1use nu_engine::{command_prelude::*, scope::ScopeData};
2
3#[derive(Clone)]
4pub struct ScopeEngineStats;
5
6impl Command for ScopeEngineStats {
7    fn name(&self) -> &str {
8        "scope engine-stats"
9    }
10
11    fn signature(&self) -> Signature {
12        Signature::build("scope engine-stats")
13            .input_output_types(vec![(Type::Nothing, Type::Any)])
14            .allow_variants_without_examples(true)
15            .category(Category::Core)
16    }
17
18    fn description(&self) -> &str {
19        "Output stats on the engine in the current state."
20    }
21
22    fn run(
23        &self,
24        engine_state: &EngineState,
25        stack: &mut Stack,
26        call: &Call,
27        _input: PipelineData,
28    ) -> Result<PipelineData, ShellError> {
29        let span = call.head;
30
31        let scope_data = ScopeData::new(engine_state, stack);
32
33        Ok(scope_data.collect_engine_state(span).into_pipeline_data())
34    }
35
36    fn examples(&self) -> Vec<Example<'_>> {
37        vec![Example {
38            description: "Show the stats on the current engine state",
39            example: "scope engine-stats",
40            result: None,
41        }]
42    }
43}
44
45#[cfg(test)]
46mod test {
47    use super::*;
48
49    #[test]
50    fn test_examples() {
51        use crate::test_examples;
52
53        test_examples(ScopeEngineStats {})
54    }
55}