use std::env;
use clap::Parser;
use crate::types::{CrawlerType, Exchange, MarketType};
#[derive(Parser, Debug)]
#[clap(about)]
pub struct State {
#[clap(short, long)]
pub address: String,
#[clap(short, long)]
pub username: String,
#[clap(short, long)]
pub password: Option<String>,
#[clap(short, long)]
pub crawler_type: CrawlerType,
#[clap(short, long)]
pub exchange: Exchange,
#[clap(short, long)]
pub market: MarketType,
#[clap(short, long)]
pub symbol: String,
#[clap(long)]
pub month: Option<String>,
#[clap(long)]
pub day: Option<String>,
#[clap(short, long)]
pub output: String,
#[clap(long, action)]
pub raw: bool,
#[clap(long, action)]
pub keep_compressed: bool,
#[clap(long, action)]
pub latest_day: bool,
#[clap(long, action)]
pub latest_month: bool,
}
pub fn load() -> State {
dotenv::dotenv().ok();
let mut state = State::parse();
if state.password == None {
state.password = match env::var("PASSWORD") {
Ok(password) => Some(password),
Err(_) => None,
};
}
state
}