Skip to content

Commit

Permalink
feat: parse env variables for global args (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuttymoon authored Apr 27, 2023
2 parents 2f5bd4d + 4a45bec commit 7f4484f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
members = ["crates/ash_cli", "crates/ash_sdk"]

[workspace.package]
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["E36 Knots"]
homepage = "https://ash.center"
Expand Down
2 changes: 1 addition & 1 deletion crates/ash_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords.workspace = true

[dependencies]
ash_sdk = { path = "../ash_sdk" }
clap = { version = "4.0.32", features = ["derive"] }
clap = { version = "4.0.32", features = ["derive", "env"] }
colored = "2.0.0"
exitcode = "1.1.2"
indent = "0.1.1"
Expand Down
3 changes: 2 additions & 1 deletion crates/ash_cli/src/avalanche/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pub(crate) struct SubnetCommand {
long,
help = "Avalanche network",
default_value = "mainnet",
global = true
global = true,
env = "AVALANCHE_NETWORK"
)]
network: String,
}
Expand Down
3 changes: 2 additions & 1 deletion crates/ash_cli/src/avalanche/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub(crate) struct ValidatorCommand {
long,
help = "Avalanche network",
default_value = "mainnet",
global = true
global = true,
env = "AVALANCHE_NETWORK"
)]
network: String,
#[arg(
Expand Down
9 changes: 7 additions & 2 deletions crates/ash_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ use std::process::exit;
struct Cli {
#[command(subcommand)]
command: CliCommands,
#[arg(long, help = "Output in JSON format", global = true)]
#[arg(long, help = "Output in JSON format", global = true, env = "ASH_JSON")]
json: bool,
#[arg(long, help = "Path to the configuration file", global = true)]
#[arg(
long,
help = "Path to the configuration file",
global = true,
env = "ASH_CONFIG"
)]
config: Option<String>,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/ash_sdk/src/avalanche/subnets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct AvalancheSubnet {
/// List of the Subnet's blockchains
pub blockchains: Vec<AvalancheBlockchain>,
/// List of the Subnet's validators
#[serde(default)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub validators: Vec<AvalancheSubnetValidator>,
}

Expand Down

0 comments on commit 7f4484f

Please sign in to comment.