Add better exit command (#369)

This commit is contained in:
JT
2021-11-26 21:00:57 +13:00
committed by GitHub
parent f052b3313d
commit 5d88ed6c75
6 changed files with 44 additions and 12 deletions

View File

@ -0,0 +1,33 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, PipelineData, ShellError, Signature};
/// Source a file for environment variables.
#[derive(Clone)]
pub struct Exit;
impl Command for Exit {
fn name(&self) -> &str {
"exit"
}
fn signature(&self) -> Signature {
Signature::build("exit").category(Category::Shells)
}
fn usage(&self) -> &str {
"Runs a script file in the current context."
}
fn run(
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<PipelineData, ShellError> {
//TODO: add more shell support
std::process::exit(0);
}
}

View File

@ -0,0 +1,3 @@
mod exit;
pub use exit::Exit;