Skip to content

Commit

Permalink
feat(term): use env var as default flag value
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed Feb 21, 2024
1 parent 7e8db96 commit c7887e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/synd_term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ synd-o11y = { path = "../synd_o11y", version = "0.1.2" }

anyhow = { workspace = true }
chrono = { workspace = true }
clap = { workspace = true, features = ["derive", "string", "color", "suggestions", "wrap_help"] }
clap = { workspace = true, features = ["derive", "string", "color", "suggestions", "wrap_help", "env"] }
crossterm = { version = "0.27.0", features = ["event-stream"] }
directories = "5.0.1"
edit = "0.1.5"
Expand Down
6 changes: 3 additions & 3 deletions crates/synd_term/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ impl From<Palette> for tailwind::Palette {
#[command(version, propagate_version = true)]
pub struct Args {
/// synd_api endpoint
#[arg(long, default_value = config::api::ENDPOINT)]
#[arg(long, default_value = config::api::ENDPOINT, env = config::env::ENDPOINT)]
pub endpoint: Url,
/// Log file path
#[arg(long, default_value = config::log_path().into_os_string())]
#[arg(long, default_value = config::log_path().into_os_string(), env = config::env::LOG_PATH)]
pub log: PathBuf,
/// Color palette
#[arg(value_enum, long = "theme", default_value_t = Palette::Slate)]
#[arg(value_enum, long = "theme", default_value_t = Palette::Slate, env = config::env::THEME)]
pub palette: Palette,
#[command(subcommand)]
pub command: Option<Command>,
Expand Down
4 changes: 4 additions & 0 deletions crates/synd_term/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub mod env {
}
/// Log directive
pub const LOG_DIRECTIVE: &str = env_key!("LOG");

pub const ENDPOINT: &str = env_key!("ENDPOINT");
pub const LOG_PATH: &str = env_key!("LOG");
pub const THEME: &str = env_key!("THEME");
}

pub const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
Expand Down

0 comments on commit c7887e9

Please sign in to comment.