Skip to content

Commit

Permalink
feat: read more cli options from environment variables
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Nov 17, 2024
1 parent ae3c622 commit 2108566
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set shell := ["bash", "-uc"]

export RUST_BACKTRACE := "1"
export RUST_LOG := ""
export CI := "1"

build:
cargo build --all-features
Expand Down
4 changes: 2 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ pub struct EntryPoint {
cmd: RusticServerCmd,

/// Enable verbose logging
#[arg(short, long, global = true)]
#[arg(short, long, global = true, env = "RUSTIC_SERVER_VERBOSE")]
pub verbose: bool,

/// Use the specified config file
#[arg(short, long, global = true)]
#[arg(short, long, global = true, env = "RUSTIC_SERVER_CONFIG_PATH")]
pub config: Option<String>,
}

Expand Down
9 changes: 5 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ pub struct TlsSettings {
default_value = "true",
help = "Enable TLS support",
requires = "tls_key",
requires = "tls_cert"
requires = "tls_cert",
env = "RUSTIC_SERVER_DISABLE_TLS"
)]
#[serde(default = "default_true")]
#[merge(strategy = conflate::bool::overwrite_true)]
Expand Down Expand Up @@ -196,7 +197,7 @@ impl Default for TlsSettings {
#[group(id = "auth")]
pub struct HtpasswdSettings {
/// Disable .htpasswd authentication
#[arg(long = "no-auth")]
#[arg(long = "no-auth", env = "RUSTIC_SERVER_DISABLE_AUTH")]
#[serde(default)]
#[merge(strategy = conflate::bool::overwrite_false)]
pub disable_auth: bool,
Expand Down Expand Up @@ -261,13 +262,13 @@ pub struct AclSettings {
pub disable_acl: bool,

/// Users can only access their private repositories
#[arg(long, default_value = "true")]
#[arg(long, default_value = "true", env = "RUSTIC_SERVER_PRIVATE_REPOS")]
#[serde(skip)]
#[merge(strategy = conflate::bool::overwrite_false)]
pub private_repos: bool,

/// Enable append only mode
#[arg(long)]
#[arg(long, env = "RUSTIC_SERVER_APPEND_ONLY")]
#[merge(strategy = conflate::bool::overwrite_false)]
pub append_only: bool,

Expand Down

0 comments on commit 2108566

Please sign in to comment.