about summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2023-11-06 05:31:38 -0600
committergennyble <gen@nyble.dev>2023-11-06 05:31:38 -0600
commit04af786fb725dedadd782709278921df190c713f (patch)
tree0ae61681f4fd759fd2861434f4d09514789783e8 /src/main.rs
parente70327c824d145274430f5f315f464d1d3fda53d (diff)
downloadpopline-04af786fb725dedadd782709278921df190c713f.tar.gz
popline-04af786fb725dedadd782709278921df190c713f.zip
exit with 0 when out of lines HEAD main
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index b5994e9..c15cc54 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,17 +1,24 @@
+use std::path::PathBuf;
+
 fn main() {
+	// We don't need anything fancy here now
 	if std::env::args().len() != 2 {
-		eprintln!("usage: popline <file>\n");
-		eprintln!("removes the first line of a file and rewrites it to disk without that line");
+		eprintln!(
+			"usage: popline <file>\n\
+			removes the first line of a file,\
+			writes it back to disk without that line"
+		);
 		std::process::exit(1);
 	}
 
-	let file = std::path::PathBuf::from(std::env::args().nth(1).unwrap());
+	// A panic is fine, really; it'll be caught while writing
+	let file = PathBuf::from(std::env::args().nth(1).unwrap());
 	let string = std::fs::read_to_string(&file).unwrap();
 	let mut lines = string.lines();
 
 	let line = match lines.next() {
 		None => {
-			std::process::exit(1);
+			std::process::exit(0);
 		}
 		Some(line) => line,
 	};