From a57319814005d370ff76d0f0b42c73be78fa26f3 Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Thu, 25 Apr 2024 01:43:29 +0530 Subject: [PATCH] feat: enable global flag for all `commands/options` (#1875) * feat: enable global flag for TransactionOptions * set global flag on all options * remove short from args --- bin/sozo/src/commands/options/account.rs | 2 ++ bin/sozo/src/commands/options/fee.rs | 3 +++ bin/sozo/src/commands/options/signer.rs | 3 +++ bin/sozo/src/commands/options/starknet.rs | 1 + bin/sozo/src/commands/options/transaction.rs | 15 ++++++++------- bin/sozo/src/commands/options/world.rs | 1 + 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index 2ad778e747..885a0c2b00 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -20,6 +20,7 @@ use super::DOJO_ACCOUNT_ADDRESS_ENV_VAR; #[command(next_help_heading = "Account options")] pub struct AccountOptions { #[arg(long, env = DOJO_ACCOUNT_ADDRESS_ENV_VAR)] + #[arg(global = true)] pub account_address: Option, #[command(flatten)] @@ -28,6 +29,7 @@ pub struct AccountOptions { #[arg(long)] #[arg(help = "Use legacy account (cairo0 account)")] + #[arg(global = true)] pub legacy: bool, } diff --git a/bin/sozo/src/commands/options/fee.rs b/bin/sozo/src/commands/options/fee.rs index bee0a5246b..2cb8c42960 100644 --- a/bin/sozo/src/commands/options/fee.rs +++ b/bin/sozo/src/commands/options/fee.rs @@ -10,12 +10,15 @@ use starknet_crypto::FieldElement; #[command(next_help_heading = "Fee options")] pub struct FeeOptions { #[clap(long, help = "Maximum transaction fee in Ether (18 decimals)")] + #[arg(global = true)] max_fee: Option, #[clap(long, help = "Maximum transaction fee in Wei")] + #[arg(global = true)] max_fee_raw: Option, #[clap(long, help = "Only estimate transaction fee without sending transaction")] + #[arg(global = true)] estimate_only: bool, } diff --git a/bin/sozo/src/commands/options/signer.rs b/bin/sozo/src/commands/options/signer.rs index 320ef0a8c3..8c36c2bea5 100644 --- a/bin/sozo/src/commands/options/signer.rs +++ b/bin/sozo/src/commands/options/signer.rs @@ -20,18 +20,21 @@ pub struct SignerOptions { #[arg(conflicts_with = "keystore_path")] #[arg(help_heading = "Signer options - RAW")] #[arg(help = "The raw private key associated with the account contract.")] + #[arg(global = true)] pub private_key: Option, #[arg(long = "keystore", env = DOJO_KEYSTORE_PATH_ENV_VAR)] #[arg(value_name = "PATH")] #[arg(help_heading = "Signer options - KEYSTORE")] #[arg(help = "Use the keystore in the given folder or file.")] + #[arg(global = true)] pub keystore_path: Option, #[arg(long = "password", env = DOJO_KEYSTORE_PASSWORD_ENV_VAR)] #[arg(value_name = "PASSWORD")] #[arg(help_heading = "Signer options - KEYSTORE")] #[arg(help = "The keystore password. Used with --keystore.")] + #[arg(global = true)] pub keystore_password: Option, } diff --git a/bin/sozo/src/commands/options/starknet.rs b/bin/sozo/src/commands/options/starknet.rs index 759cacbf70..91cce0b5dd 100644 --- a/bin/sozo/src/commands/options/starknet.rs +++ b/bin/sozo/src/commands/options/starknet.rs @@ -13,6 +13,7 @@ pub struct StarknetOptions { #[arg(long, env = STARKNET_RPC_URL_ENV_VAR)] #[arg(value_name = "URL")] #[arg(help = "The Starknet RPC endpoint.")] + #[arg(global = true)] pub rpc_url: Option, } diff --git a/bin/sozo/src/commands/options/transaction.rs b/bin/sozo/src/commands/options/transaction.rs index 4ac661f21d..6349fb3377 100644 --- a/bin/sozo/src/commands/options/transaction.rs +++ b/bin/sozo/src/commands/options/transaction.rs @@ -5,34 +5,35 @@ use starknet::core::types::FieldElement; #[derive(Debug, Args)] #[command(next_help_heading = "Transaction options")] pub struct TransactionOptions { - #[arg(long)] - #[arg(value_name = "MULTIPLIER")] + #[arg(long, value_name = "MULTIPLIER")] #[arg(help = "The multiplier to use for the fee estimate.")] #[arg(long_help = "The multiplier to use for the fee estimate. This value will be used on \ the estimated fee which will be used as the max fee for the transaction. \ (max_fee = estimated_fee * multiplier)")] #[arg(conflicts_with = "max_fee_raw")] + #[arg(global = true)] pub fee_estimate_multiplier: Option, - #[arg(short, long)] + #[arg(long)] #[arg(help = "Maximum raw value to be used for fees, in Wei.")] #[arg(conflicts_with = "fee_estimate_multiplier")] + #[arg(global = true)] pub max_fee_raw: Option, - #[arg(short, long)] + #[arg(long)] #[arg(help = "Wait until the transaction is accepted by the sequencer, returning the status \ and hash.")] #[arg(long_help = "Wait until the transaction is accepted by the sequencer, returning the \ status and the hash. This will poll the transaction status until it gets \ accepted or rejected by the sequencer.")] + #[arg(global = true)] pub wait: bool, - #[arg(short, long)] + #[arg(long)] #[arg( help = "If --wait is set, returns the full transaction receipt. Otherwise, it is a no-op." )] - #[arg(long_help = "If --wait is set, returns the full transaction receipt. Otherwise, it is \ - a no-op.")] + #[arg(global = true)] pub receipt: bool, } diff --git a/bin/sozo/src/commands/options/world.rs b/bin/sozo/src/commands/options/world.rs index 7a54617e7a..c8fe9d5be9 100644 --- a/bin/sozo/src/commands/options/world.rs +++ b/bin/sozo/src/commands/options/world.rs @@ -12,6 +12,7 @@ use super::DOJO_WORLD_ADDRESS_ENV_VAR; pub struct WorldOptions { #[arg(help = "The address of the World contract.")] #[arg(long = "world", env = DOJO_WORLD_ADDRESS_ENV_VAR)] + #[arg(global = true)] pub world_address: Option, }