Skip to content
Snippets Groups Projects

refac call submission and event watch

Merged Hugo Trentesaux requested to merge hugo-dev into master
2 files
+ 26
1
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 20
1
@@ -27,6 +27,25 @@ impl std::default::Default for Config {
}
}
impl std::fmt::Display for Config {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let secret = if self.secret.is_some() {
"(secret defined)"
} else {
"(no secret)"
};
let address = if let Some(address) = &self.address {
format!("{}", address)
} else {
"(no address)".to_string()
};
writeln!(f, "Ğcli config")?;
writeln!(f, "duniter endpoint {}", self.duniter_endpoint)?;
writeln!(f, "indexer endpoint {}", self.indexer_endpoint)?;
write!(f, "address {address} {secret}")
}
}
/// load config file and manage error if could not
pub fn load_conf() -> Config {
match confy::load(APP_NAME, None) {
@@ -68,7 +87,7 @@ pub fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<()> {
);
}
Subcommand::Show => {
println!("{:?}", data.cfg);
println!("{}", data.cfg);
}
Subcommand::Save => {
confy::store(APP_NAME, None, &data.cfg).expect("unable to write config");
Loading