Skip to content

Commit

Permalink
fixed --help flag output
Browse files Browse the repository at this point in the history
  • Loading branch information
splurf committed Jan 16, 2024
1 parent 3fe71ed commit 9e02688
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {

#[derive(Parser)]
#[command(author, version, about)]
struct Config {
pub struct Config {
#[arg(short, long)]
email: String,

Expand All @@ -32,6 +32,12 @@ struct Config {
delay: Duration,
}

impl Default for Config {
fn default() -> Self {
Self::parse()
}
}

pub struct BaseClient {
client: Client,
body: Body,
Expand All @@ -46,15 +52,15 @@ impl BaseClient {
PublicIpAPI::Ifconfig,
];

pub fn setup() -> Result<Self> {
let Config {
pub fn setup(
Config {
email,
api_token,
zone_id,
id,
delay,
} = Config::parse();

}: Config,
) -> Result<Self> {
let client = Client::default();
let builder_fn = Box::new(move |method: Method, client: &Client| -> RequestBuilder {
client
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ mod util;
use {cfg::*, err::*, util::*};

fn main() -> Result<()> {
let mut client = dbg("Initializing client", || BaseClient::setup())?;
let cfg = Config::default();
let mut client = dbg("Initializing client", || BaseClient::setup(cfg))?;

loop {
match dbg("Doing routine", || routine(&mut client)) {
Expand Down

0 comments on commit 9e02688

Please sign in to comment.