-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gorc: config can leverage defaults better; print-config can show your…
… actual config or defaults (#136)
- Loading branch information
Showing
2 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
use abscissa_core::{Runnable, Command,Options}; | ||
use crate::config::GorcConfig; | ||
use crate::{application::APP, prelude::*}; | ||
use abscissa_core::{Command, Options, Runnable}; | ||
|
||
#[derive(Command, Debug, Default, Options)] | ||
pub struct PrintConfigCmd {} | ||
pub struct PrintConfigCmd { | ||
#[options(help = "should default config")] | ||
show_default: bool, | ||
} | ||
|
||
impl Runnable for PrintConfigCmd { | ||
fn run(&self) { | ||
let config = crate::config::GorcConfig::default(); | ||
let config = if self.show_default { | ||
GorcConfig::default() | ||
} else { | ||
let config = APP.config(); | ||
GorcConfig { | ||
keystore: config.keystore.to_owned(), | ||
gravity: config.gravity.to_owned(), | ||
ethereum: config.ethereum.to_owned(), | ||
cosmos: config.cosmos.to_owned(), | ||
metrics: config.metrics.to_owned(), | ||
} | ||
}; | ||
|
||
print!("{}", toml::to_string(&config).unwrap()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters