mirror of
https://github.com/nushell/nushell.git
synced 2025-08-12 06:59:16 +02:00
Add better exit command (#369)
This commit is contained in:
33
crates/nu-command/src/shells/exit.rs
Normal file
33
crates/nu-command/src/shells/exit.rs
Normal 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);
|
||||
}
|
||||
}
|
3
crates/nu-command/src/shells/mod.rs
Normal file
3
crates/nu-command/src/shells/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod exit;
|
||||
|
||||
pub use exit::Exit;
|
Reference in New Issue
Block a user