aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index bedcb74..e90bfed 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -80,12 +80,15 @@ impl PidFile {
80 let lines: Vec<&str> = contents.lines().collect(); 80 let lines: Vec<&str> = contents.lines().collect();
81 81
82 if lines.is_empty() { 82 if lines.is_empty() {
83 return Err(PidFileReadError::FileInvalid("PID file is empty".to_string())); 83 return Err(PidFileReadError::FileInvalid(
84 "PID file is empty".to_string(),
85 ));
84 } 86 }
85 87
86 let pid = lines[0].trim().parse::<u32>().map_err(|_| { 88 let pid = lines[0]
87 PidFileReadError::FileInvalid("Invalid PID on first line".to_string()) 89 .trim()
88 })?; 90 .parse::<u32>()
91 .map_err(|_| PidFileReadError::FileInvalid("Invalid PID on first line".to_string()))?;
89 92
90 let command: Vec<String> = lines[1..].iter().map(|line| line.to_string()).collect(); 93 let command: Vec<String> = lines[1..].iter().map(|line| line.to_string()).collect();
91 94
@@ -647,7 +650,10 @@ fn list_daemons(quiet: bool) -> Result<()> {
647 println!("{}:{}:{}", id, pid_file_data.pid, status); 650 println!("{}:{}:{}", id, pid_file_data.pid, status);
648 } else { 651 } else {
649 let command = pid_file_data.command_string(); 652 let command = pid_file_data.command_string();
650 println!("{:<20} {:<8} {:<10} {}", id, pid_file_data.pid, status, command); 653 println!(
654 "{:<20} {:<8} {:<10} {}",
655 id, pid_file_data.pid, status, command
656 );
651 } 657 }
652 } 658 }
653 Err(PidFileReadError::FileNotFound) => { 659 Err(PidFileReadError::FileNotFound) => {
@@ -665,10 +671,7 @@ fn list_daemons(quiet: bool) -> Result<()> {
665 if quiet { 671 if quiet {
666 println!("{}:INVALID:ERROR", id); 672 println!("{}:INVALID:ERROR", id);
667 } else { 673 } else {
668 println!( 674 println!("{:<20} {:<8} {:<10} {}", id, "INVALID", "ERROR", reason);
669 "{:<20} {:<8} {:<10} {}",
670 id, "INVALID", "ERROR", reason
671 );
672 } 675 }
673 } 676 }
674 Err(PidFileReadError::IoError(_)) => { 677 Err(PidFileReadError::IoError(_)) => {