mirror of
https://github.com/mimblewimble/mwixnet.git
synced 2025-01-20 19:11:09 +03:00
Merge pull request #29 from yeastplume/output_address
Add option to output public address
This commit is contained in:
commit
e66a3b9bbe
2 changed files with 32 additions and 1 deletions
|
@ -116,6 +116,28 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let password = prompt_password();
|
||||
let mut server_config = config::load_config(&config_path, &password)?;
|
||||
|
||||
// Write a new config file if init-config command is supplied
|
||||
if let ("address", Some(_)) = args.subcommand() {
|
||||
if !config_path.exists() {
|
||||
panic!(
|
||||
"No public address configured (Config file not found). {}",
|
||||
config_path.to_string_lossy()
|
||||
);
|
||||
}
|
||||
let sub_args = args.subcommand_matches("address").unwrap();
|
||||
if sub_args.is_present("output_file")
|
||||
{
|
||||
//output onion address to file
|
||||
let output_file = sub_args.value_of("output_file").unwrap();
|
||||
let onion_address = server_config.onion_address();
|
||||
std::fs::write(output_file, format!("{}", onion_address))?;
|
||||
println!("Onion address written to file: {}", output_file);
|
||||
} else {
|
||||
println!("{}", server_config.onion_address());
|
||||
}
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
// Override grin_node_url, if supplied
|
||||
if let Some(grin_node_url) = grin_node_url {
|
||||
server_config.grin_node_url = grin_node_url.parse()?;
|
||||
|
|
|
@ -48,4 +48,13 @@ args:
|
|||
takes_value: true
|
||||
subcommands:
|
||||
- init-config:
|
||||
about: Writes a new configuration file
|
||||
about: Writes a new configuration file
|
||||
- address:
|
||||
about: Outputs the public key of the server
|
||||
args:
|
||||
- output_file:
|
||||
help: Path to output the public key to
|
||||
long: output_file
|
||||
short: o
|
||||
takes_value: true
|
||||
required: false
|
Loading…
Reference in a new issue