mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 17:14:23 +01:00
Add ppid to ps command (#8750)
# Description Adds the `ppid` field that's available on all supported platforms to the `ps` command. This would be useful in my scripts. # User-Facing Changes - ps output now contains an extra column # Tests + Formatting Not sure if I need to add a test for this # After Submitting Update https://www.nushell.sh/book/quick_tour.html#quick-tour to show the new table
This commit is contained in:
parent
50ca77437d
commit
65c90d5b45
@ -86,6 +86,12 @@ fn run_ps(engine_state: &EngineState, call: &Call) -> Result<PipelineData, Shell
|
||||
span,
|
||||
});
|
||||
|
||||
cols.push("ppid".to_string());
|
||||
vals.push(Value::Int {
|
||||
val: proc.ppid() as i64,
|
||||
span,
|
||||
});
|
||||
|
||||
cols.push("name".to_string());
|
||||
vals.push(Value::String {
|
||||
val: proc.name(),
|
||||
|
@ -131,6 +131,11 @@ impl ProcessInfo {
|
||||
self.pid
|
||||
}
|
||||
|
||||
/// PPID of process
|
||||
pub fn ppid(&self) -> i32 {
|
||||
self.ppid
|
||||
}
|
||||
|
||||
/// Name of command
|
||||
pub fn name(&self) -> String {
|
||||
self.command()
|
||||
|
@ -302,6 +302,11 @@ impl ProcessInfo {
|
||||
self.pid
|
||||
}
|
||||
|
||||
/// Parent PID of process
|
||||
pub fn ppid(&self) -> i32 {
|
||||
self.ppid
|
||||
}
|
||||
|
||||
/// Name of command
|
||||
pub fn name(&self) -> String {
|
||||
if let Some(path) = &self.curr_path {
|
||||
|
@ -1006,6 +1006,11 @@ impl ProcessInfo {
|
||||
self.pid
|
||||
}
|
||||
|
||||
/// Parent PID of process
|
||||
pub fn ppid(&self) -> i32 {
|
||||
self.ppid
|
||||
}
|
||||
|
||||
/// Name of command
|
||||
pub fn name(&self) -> String {
|
||||
self.command.clone()
|
||||
|
Loading…
Reference in New Issue
Block a user