Skip to content

Commit

Permalink
🐛 fix transfer bug and change the behavior of saving history commands
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Jun 21, 2018
1 parent 8ff7542 commit a3d29d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
31 changes: 14 additions & 17 deletions cita-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,23 +1133,20 @@ pub fn transfer_processor(
let mut client = Client::new()
.map_err(|err| format!("{}", err))?
.set_debug(debug);
match sub_matches.subcommand() {
("transfer", Some(m)) => {
let blake2b = blake2b(m, env_variable);
client.set_private_key(parse_privkey(m.value_of("admin-private").unwrap())?);
let url = url.unwrap_or_else(|| get_url(m));
let address = m.value_of("address").unwrap();
let quota = m.value_of("quota").map(|quota| parse_u64(quota).unwrap());
let value = parse_u64(m.value_of("value").unwrap()).unwrap();
let is_color = !sub_matches.is_present("no-color") && env_variable.color();
let response = client
.transfer(url, value, address, quota, blake2b)
.map_err(|err| format!("{}", err))?;
printer.println(&response, is_color);
Ok(())
}
_ => return Err(sub_matches.usage().to_owned()),
}
let blake2b = blake2b(sub_matches, env_variable);
client.set_private_key(parse_privkey(sub_matches.value_of("private-key").unwrap())?);
let url = url.unwrap_or_else(|| get_url(sub_matches));
let address = sub_matches.value_of("address").unwrap();
let quota = sub_matches
.value_of("quota")
.map(|quota| parse_u64(quota).unwrap());
let value = parse_u64(sub_matches.value_of("value").unwrap())?;
let is_color = !sub_matches.is_present("no-color") && env_variable.color();
let response = client
.transfer(url, value, address, quota, blake2b)
.map_err(|err| format!("{}", err))?;
printer.println(&response, is_color);
Ok(())
}

/// System contract
Expand Down
10 changes: 6 additions & 4 deletions cita-cli/src/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ pub fn start(url: &str) -> io::Result<()> {
env_variable.print(&url);
Ok(())
}
("exit", _) => break,
("exit", _) => {
if let Err(err) = interface.save_history(history_file) {
eprintln!("Save command history failed: {}", err);
};
break;
}
_ => Ok(()),
}
}
Expand All @@ -170,9 +175,6 @@ pub fn start(url: &str) -> io::Result<()> {
}

interface.add_history_unique(line.clone());
if let Err(err) = interface.save_history(history_file) {
eprintln!("Save command history failed: {}", err);
};
}

Ok(())
Expand Down

0 comments on commit a3d29d8

Please sign in to comment.