Move solana-keygen into keygen/

This commit is contained in:
Michael Vines
2018-12-12 13:30:00 -08:00
parent cafeef33c3
commit 282d4a3563
9 changed files with 82 additions and 8 deletions

View File

@ -10,7 +10,9 @@ license = "Apache-2.0"
bincode = "1.0.0"
byteorder = "1.2.1"
bs58 = "0.2.0"
dirs = "1.0.2"
chrono = { version = "0.4.0", features = ["serde"] }
clap = "2.31"
generic-array = { version = "0.12.0", default-features = false, features = ["serde"] }
log = "0.4.2"
ring = "0.13.2"
@ -20,3 +22,8 @@ serde_derive = "1.0.82"
serde_json = "1.0.10"
untrusted = "0.6.2"
[[bin]]
name = "solana-keygen"
path = "src/bin/keygen.rs"

36
sdk/src/bin/keygen.rs Normal file
View File

@ -0,0 +1,36 @@
#[macro_use]
extern crate clap;
extern crate dirs;
extern crate solana_sdk;
use clap::{App, Arg};
use solana_sdk::signature::gen_keypair_file;
use std::error;
fn main() -> Result<(), Box<dyn error::Error>> {
let matches = App::new("solana-keygen")
.version(crate_version!())
.arg(
Arg::with_name("outfile")
.short("o")
.long("outfile")
.value_name("PATH")
.takes_value(true)
.help("Path to generated file"),
)
.get_matches();
let mut path = dirs::home_dir().expect("home directory");
let outfile = if matches.is_present("outfile") {
matches.value_of("outfile").unwrap()
} else {
path.extend(&[".config", "solana", "id.json"]);
path.to_str().unwrap()
};
let serialized_keypair = gen_keypair_file(outfile.to_string())?;
if outfile == "-" {
println!("{}", serialized_keypair);
}
Ok(())
}