-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add global config for default network and identity.
- Loading branch information
Showing
10 changed files
with
344 additions
and
10 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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::{ | ||
commands::global, | ||
config::locator::{self, config, config_file}, | ||
}; | ||
use clap::Parser; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct Cmd { | ||
#[command(flatten)] | ||
pub config_locator: locator::Args, | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Locator(#[from] locator::Error), | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self, _global_args: &global::Args) -> Result<(), Error> { | ||
let config = config()?; | ||
|
||
println!("config_file={}", config_file()?.to_string_lossy()); | ||
|
||
println!( | ||
"network={}", | ||
config.defaults.network.unwrap_or("(unset)".to_string()) | ||
); | ||
|
||
println!( | ||
"identity={}", | ||
config.defaults.identity.unwrap_or("(unset)".to_string()) | ||
); | ||
|
||
Ok(()) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use clap::command; | ||
|
||
use crate::{commands::global, config::locator, print::Print}; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Config(#[from] locator::Error), | ||
} | ||
|
||
#[derive(Debug, clap::Parser, Clone)] | ||
#[group(skip)] | ||
pub struct Cmd { | ||
/// Set the default network name. | ||
pub name: String, | ||
|
||
#[command(flatten)] | ||
pub config_locator: locator::Args, | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self, global_args: &global::Args) -> Result<(), Error> { | ||
let printer = Print::new(global_args.quiet); | ||
let _ = self.config_locator.read_identity(&self.name)?; | ||
|
||
self.config_locator.write_default_identity(&self.name)?; | ||
|
||
printer.infoln(format!( | ||
"The default source account is set to `{}`", | ||
self.name, | ||
)); | ||
|
||
Ok(()) | ||
} | ||
} |
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
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
Oops, something went wrong.