mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
Fix ps
command to show process name only (#4544)
* Fix `ps` command to show process name only * Remove `command_only` - it is no longer being used
This commit is contained in:
parent
da42100374
commit
3ecf17e7af
@ -303,13 +303,21 @@ impl ProcessInfo {
|
|||||||
|
|
||||||
/// Name of command
|
/// Name of command
|
||||||
pub fn name(&self) -> String {
|
pub fn name(&self) -> String {
|
||||||
// self.command()
|
if let Some(path) = &self.curr_path {
|
||||||
// .split(' ')
|
if !path.cmd.is_empty() {
|
||||||
// .collect::<Vec<_>>()
|
let command_path = &path.exe;
|
||||||
// .first()
|
|
||||||
// .map(|x| x.to_string())
|
if let Some(command_name) = command_path.file_name() {
|
||||||
// .unwrap_or_default()
|
command_name.to_string_lossy().to_string()
|
||||||
self.command_only()
|
} else {
|
||||||
|
command_path.to_string_lossy().to_string()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String::from("")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String::from("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Full name of command, with arguments
|
/// Full name of command, with arguments
|
||||||
@ -325,19 +333,6 @@ impl ProcessInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Full name of comand only
|
|
||||||
pub fn command_only(&self) -> String {
|
|
||||||
if let Some(path) = &self.curr_path {
|
|
||||||
if !path.cmd.is_empty() {
|
|
||||||
path.exe.to_string_lossy().to_string()
|
|
||||||
} else {
|
|
||||||
String::from("")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String::from("")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the status of the process
|
/// Get the status of the process
|
||||||
pub fn status(&self) -> String {
|
pub fn status(&self) -> String {
|
||||||
let mut state = 7;
|
let mut state = 7;
|
||||||
|
Loading…
Reference in New Issue
Block a user