Skip to content

Commit

Permalink
In Wallet, make --tokens required and --to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
garious committed Jul 12, 2018
1 parent 814457b commit 06f1520
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/bin/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn parse_args() -> Result<WalletConfig, Box<error::Error>> {
.long("tokens")
.value_name("NUMBER")
.takes_value(true)
.required(true)
.help("The number of tokens to request"),
),
)
Expand All @@ -121,7 +122,6 @@ fn parse_args() -> Result<WalletConfig, Box<error::Error>> {
.long("to")
.value_name("PUBKEY")
.takes_value(true)
.required(true)
.help("The pubkey of recipient"),
),
)
Expand Down Expand Up @@ -155,11 +155,7 @@ fn parse_args() -> Result<WalletConfig, Box<error::Error>> {

let command = match matches.subcommand() {
("airdrop", Some(airdrop_matches)) => {
let tokens = if airdrop_matches.is_present("tokens") {
airdrop_matches.value_of("tokens").unwrap().parse()?
} else {
100
};
let tokens = airdrop_matches.value_of("tokens").unwrap().parse()?
Ok(WalletCommand::AirDrop(tokens))
}
("pay", Some(pay_matches)) => {
Expand All @@ -177,11 +173,7 @@ fn parse_args() -> Result<WalletConfig, Box<error::Error>> {
id.pubkey()
};

let tokens = if pay_matches.is_present("tokens") {
pay_matches.value_of("tokens").unwrap().parse()?
} else {
10
};
let tokens = airdrop_matches.value_of("tokens").unwrap().parse()?

Ok(WalletCommand::Pay(tokens, to))
}
Expand Down

0 comments on commit 06f1520

Please sign in to comment.