30 lines
872 B
Rust
30 lines
872 B
Rust
use std::env;
|
|
use std::io;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() -> io::Result<()> {
|
|
let mut arguments = env::args_os();
|
|
let program = arguments.next().unwrap_or_else(|| "rust_cli".into());
|
|
let Some(destination) = arguments.next() else {
|
|
return Err(io::Error::new(
|
|
io::ErrorKind::InvalidInput,
|
|
format!("usage: {} <destination>", PathBuf::from(program).display()),
|
|
));
|
|
};
|
|
|
|
if destination == "--help" {
|
|
println!("usage: {} <destination>", PathBuf::from(program).display());
|
|
return Ok(());
|
|
}
|
|
if arguments.next().is_some() {
|
|
return Err(io::Error::new(
|
|
io::ErrorKind::InvalidInput,
|
|
"expected exactly one destination",
|
|
));
|
|
}
|
|
|
|
let destination = rust::run(&PathBuf::from(destination))?;
|
|
println!("created {}", destination.display());
|
|
Ok(())
|
|
}
|