Files
solana/keygen/src/keygen.rs

32 lines
919 B
Rust
Raw Normal View History

2018-12-14 20:39:10 -08:00
use clap::{crate_version, App, Arg};
use solana_sdk::signature::gen_keypair_file;
use std::error;
fn main() -> Result<(), Box<dyn error::Error>> {
2018-07-12 17:29:10 -06:00
let matches = App::new("solana-keygen")
.version(crate_version!())
2018-07-12 16:29:49 -06:00
.arg(
Arg::with_name("outfile")
.short("o")
.long("outfile")
.value_name("PATH")
.takes_value(true)
2018-09-14 16:32:57 -06:00
.help("Path to generated file"),
)
.get_matches();
2018-07-12 16:29:49 -06:00
2018-07-12 18:16:30 -06:00
let mut path = dirs::home_dir().expect("home directory");
2018-07-12 17:04:42 -06:00
let outfile = if matches.is_present("outfile") {
matches.value_of("outfile").unwrap()
} else {
path.extend(&[".config", "solana", "id.json"]);
path.to_str().unwrap()
};
2018-07-12 16:29:49 -06:00
let serialized_keypair = gen_keypair_file(outfile.to_string())?;
2018-07-12 16:29:49 -06:00
if outfile == "-" {
println!("{}", serialized_keypair);
2018-07-12 16:29:49 -06:00
}
Ok(())
}