mirror of
https://github.com/nushell/nushell.git
synced 2025-02-02 11:39:55 +01:00
Clarify exec
help message; Update to engine-p (#3588)
* Fix and clarify description of 'exec' Most importantly, I added the information that it replaces the current process. * Convert exec to OutputStream; Remove unused trait * Remove dead code & unused imports on non-unix
This commit is contained in:
parent
e8dfd4ba39
commit
2591050fbe
@ -2,12 +2,15 @@ use crate::prelude::*;
|
|||||||
use nu_engine::WholeStreamCommand;
|
use nu_engine::WholeStreamCommand;
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Signature, SyntaxShape};
|
use nu_protocol::{Signature, SyntaxShape};
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
use nu_source::Tagged;
|
use nu_source::Tagged;
|
||||||
|
#[cfg(unix)]
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub struct Exec;
|
pub struct Exec;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[cfg(unix)]
|
||||||
pub struct ExecArgs {
|
pub struct ExecArgs {
|
||||||
pub command: Tagged<PathBuf>,
|
pub command: Tagged<PathBuf>,
|
||||||
pub rest: Vec<Tagged<String>>,
|
pub rest: Vec<Tagged<String>>,
|
||||||
@ -23,22 +26,26 @@ impl WholeStreamCommand for Exec {
|
|||||||
.required("command", SyntaxShape::FilePath, "the command to execute")
|
.required("command", SyntaxShape::FilePath, "the command to execute")
|
||||||
.rest(
|
.rest(
|
||||||
SyntaxShape::GlobPattern,
|
SyntaxShape::GlobPattern,
|
||||||
"any additional arguments for command",
|
"any additional arguments for the command",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"Execute command."
|
"Execute a command, replacing the current process."
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn extra_usage(&self) -> &str {
|
||||||
|
"Currently supported only on Unix-based systems."
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
exec(args)
|
exec(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Execute 'ps aux'",
|
description: "Execute external 'ps aux' tool",
|
||||||
example: "exec ps aux",
|
example: "exec ps aux",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
@ -52,7 +59,7 @@ impl WholeStreamCommand for Exec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn exec(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn exec(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
use std::os::unix::process::CommandExt;
|
use std::os::unix::process::CommandExt;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
@ -79,7 +86,7 @@ fn exec(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
fn exec(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn exec(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
Err(ShellError::labeled_error(
|
Err(ShellError::labeled_error(
|
||||||
"Error on exec",
|
"Error on exec",
|
||||||
"exec is not supported on your platform",
|
"exec is not supported on your platform",
|
||||||
|
Loading…
Reference in New Issue
Block a user