feat(scaffolding): add Rust package generator
This commit is contained in:
1 parent
d342370b89
commit
a5bc1d5303
12 files changed
+387
No files matched your search
@@ -0,0 +1,29 @@
|
||||
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(())
|
||||
}
|
||||
Reference in new issue
Block a user