Skip to content

Commit

Permalink
feat(cli): support defining the strategy with env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
graelo committed Aug 18, 2022
1 parent 521ebc6 commit 9ede704
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ categories = ["command-line-utilities"]
exclude = ["/.github", "/ci", "/.travis.yml", "/appveyor.yml"]

[dependencies]
clap = { version = "3.2.16", features = ["derive"] }
clap = { version = "3.2.16", features = ["derive", "env"] }

anyhow = "1"
thiserror = "1"
Expand Down
9 changes: 6 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,19 @@ pub struct Config {
short = 'k',
long="strategy-most-recent",
value_name = "NUMBER",
value_parser = clap::value_parser!(u16).range(1..)
value_parser = clap::value_parser!(u16).range(1..),
env = "TMUX_REVIVE_STRATEGY_MOST_RECENT"
)]
strategy_most_recent: Option<u16>,

/// Apply a classic backup strategy (keep last hour, then last day, then last week, then last month).
/// Apply a classic backup strategy (keep last hour, then last day, then last week, then last
/// month).
#[clap(
group = "strategy",
short = 'l',
long = "strategy-classic",
value_parser
value_parser,
env = "TMUX_REVIVE_STRATEGY_CLASSIC"
)]
strategy_classic: bool,

Expand Down

0 comments on commit 9ede704

Please sign in to comment.