Move solana-keygen into keygen/
This commit is contained in:
17
keygen/Cargo.toml
Normal file
17
keygen/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "solana-keygen"
|
||||
version = "0.11.0"
|
||||
description = "Solana key generation utility"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
dirs = "1.0.2"
|
||||
clap = "2.31"
|
||||
solana-sdk = { path = "../sdk", version = "0.11.0" }
|
||||
|
||||
[[bin]]
|
||||
name = "solana-keygen"
|
||||
path = "src/keygen.rs"
|
||||
|
36
keygen/src/keygen.rs
Normal file
36
keygen/src/keygen.rs
Normal 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(())
|
||||
}
|
Reference in New Issue
Block a user