Skip to main content

nu_command/filesystem/idx/
drop.rs

1use super::state::drop_runtime;
2use nu_engine::command_prelude::*;
3
4#[derive(Clone)]
5pub struct IdxDrop;
6
7impl Command for IdxDrop {
8    fn name(&self) -> &str {
9        "idx drop"
10    }
11
12    fn signature(&self) -> Signature {
13        Signature::build(self.name())
14            .input_output_types(vec![(Type::Nothing, Type::record())])
15            .category(Category::FileSystem)
16    }
17
18    fn description(&self) -> &str {
19        "Drop the current idx runtime from memory."
20    }
21
22    fn extra_description(&self) -> &str {
23        "Use this when you want to free the in-memory index completely before reinitializing or restoring a different snapshot."
24    }
25
26    fn run(
27        &self,
28        _engine_state: &EngineState,
29        _stack: &mut Stack,
30        call: &Call,
31        _input: PipelineData,
32    ) -> Result<PipelineData, ShellError> {
33        Ok(PipelineData::value(drop_runtime(call.head)?, None))
34    }
35}