From caaa14c124bca292f688464f2561b103e92871f1 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Tue, 7 May 2024 13:13:25 -0700 Subject: [PATCH] feat: print usage when running `patch` without args (#124) --- patch/src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/patch/src/main.rs b/patch/src/main.rs index f56c94c7..03a6e8c2 100644 --- a/patch/src/main.rs +++ b/patch/src/main.rs @@ -11,6 +11,23 @@ use std::time::Instant; fn main() { let mut args = std::env::args(); + if args.len() < 4 { + eprintln!( + "Usage: {} ", + std::path::Path::new(&args.next().unwrap()) + .file_name() + .unwrap() + .to_str() + .unwrap() + ); + eprintln!(" base: Path to the base file"); + eprintln!(" new: Path to the new file"); + eprintln!(" output: Path to the output patch file"); + eprintln!(""); + eprintln!(" This is an internal tool for creating binary diffs."); + std::process::exit(1); + } + args.next(); // skip program name let older = args.next().expect("path to base file"); let newer = args.next().expect("path to new file");