Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ensure short args consistency #386

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/pop-cli/src/commands/build/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub struct BuildParachainCommand {
#[arg(long)]
pub(crate) path: Option<PathBuf>,
/// The package to be built.
#[arg(short = 'p', long)]
#[arg(short, long)]
pub(crate) package: Option<String>,
/// Build profile [default: debug].
#[clap(long, value_enum)]
pub(crate) profile: Option<Profile>,
/// Parachain ID to be used when generating the chain spec files.
#[arg(short = 'i', long = "id")]
#[arg(short, long)]
pub(crate) id: Option<u32>,
// Deprecation flag, used to specify whether the deprecation warning is shown.
#[clap(skip)]
Expand Down
18 changes: 9 additions & 9 deletions crates/pop-cli/src/commands/build/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,38 +136,38 @@ pub(crate) enum RelayChain {
pub struct BuildSpecCommand {
/// File name for the resulting spec. If a path is given,
/// the necessary directories will be created
#[arg(short = 'o', long = "output")]
#[arg(short, long = "output")]
pub(crate) output_file: Option<PathBuf>,
/// [DEPRECATED] and will be removed in v0.7.0, use `profile`.
#[arg(short = 'r', long, conflicts_with = "profile")]
#[arg(short = 'R', long, conflicts_with = "profile")]
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) release: bool,
/// Build profile for the binary to generate the chain specification.
#[arg(long, value_enum)]
pub(crate) profile: Option<Profile>,
/// Parachain ID to be used when generating the chain spec files.
#[arg(short = 'i', long)]
#[arg(short, long)]
pub(crate) id: Option<u32>,
/// Whether to keep localhost as a bootnode.
#[arg(long)]
#[arg(short = 'b', long)]
pub(crate) default_bootnode: bool,
/// Type of the chain.
#[arg(short = 't', long = "type", value_enum)]
pub(crate) chain_type: Option<ChainType>,
/// Provide the chain specification to use (e.g. dev, local, custom or a path to an existing
/// file).
#[arg(short = 'c', long = "chain")]
#[arg(short, long)]
pub(crate) chain: Option<String>,
/// Relay chain this parachain will connect to.
#[arg(long, value_enum)]
#[arg(short = 'r', long, value_enum)]
pub(crate) relay: Option<RelayChain>,
/// Protocol-id to use in the specification.
#[arg(long = "protocol-id")]
#[arg(short = 'P', long = "protocol-id")]
pub(crate) protocol_id: Option<String>,
/// Whether the genesis state file should be generated.
#[arg(long = "genesis-state")]
#[arg(short = 'S', long = "genesis-state")]
pub(crate) genesis_state: bool,
/// Whether the genesis code file should be generated.
#[arg(long = "genesis-code")]
#[arg(short = 'C', long = "genesis-code")]
pub(crate) genesis_code: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/pop-cli/src/commands/call/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct CallChainCommand {
#[arg(short = 'S', long)]
sudo: bool,
/// Automatically signs and submits the extrinsic without prompting for confirmation.
#[arg(short('y'), long)]
#[arg(short = 'y', long)]
skip_confirm: bool,
}

Expand Down
14 changes: 7 additions & 7 deletions crates/pop-cli/src/commands/call/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
#[arg(short, long)]
path: Option<PathBuf>,
/// The address of the contract to call.
#[arg(name = "contract", short, long, env = "CONTRACT")]
#[arg(short, long, env = "CONTRACT")]
contract: Option<String>,
/// The name of the contract message to call.
#[arg(long, short)]
#[arg(short, long)]
message: Option<String>,
/// The message arguments, encoded as strings.
#[arg(short, long, num_args = 0..,)]
args: Vec<String>,
/// The value to be transferred as part of the call.
#[arg(name = "value", short, long, default_value = DEFAULT_PAYABLE_VALUE)]
#[arg(short, long, default_value = DEFAULT_PAYABLE_VALUE)]
value: String,
/// Maximum amount of gas to be used for this command.
/// If not specified it will perform a dry-run to estimate the gas consumed for the
Expand All @@ -45,24 +45,24 @@
#[arg(short = 'P', long)]
proof_size: Option<u64>,
/// Websocket endpoint of a node.
#[arg(name = "url", short, long, value_parser, default_value = DEFAULT_URL)]
#[arg(short, long, value_parser, default_value = DEFAULT_URL)]
url: url::Url,
/// Secret key URI for the account calling the contract.
///
/// e.g.
/// - for a dev account "//Alice"
/// - with a password "//Alice///SECRET_PASSWORD"
#[arg(name = "suri", long, short, default_value = DEFAULT_URI)]
#[arg(short, long, default_value = DEFAULT_URI)]
suri: String,
/// Submit an extrinsic for on-chain execution.
#[arg(short('x'), long)]
#[arg(short = 'x', long)]
execute: bool,
/// Perform a dry-run via RPC to estimate the gas usage. This does not submit a transaction.
#[arg(short = 'D', long, conflicts_with = "execute")]
dry_run: bool,
/// Enables developer mode, bypassing certain user prompts for faster testing.
/// Recommended for testing and local development only.
#[arg(name = "dev", long, short, default_value = "false")]
#[arg(name = "dev", short, long, default_value = "false")]
dev_mode: bool,
}
impl CallContractCommand {
Expand Down Expand Up @@ -165,7 +165,7 @@
fn is_contract_build_required(&self) -> bool {
self.path
.as_ref()
.map(|p| p.is_dir() && !has_contract_been_built(Some(&p)))

Check warning on line 168 in crates/pop-cli/src/commands/call/contract.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/pop-cli/src/commands/call/contract.rs:168:57 | 168 | .map(|p| p.is_dir() && !has_contract_been_built(Some(&p))) | ^^ help: change this to: `p` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
.unwrap_or_default()
}

Expand Down
2 changes: 1 addition & 1 deletion crates/pop-cli/src/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#[derive(Args)]
pub struct CleanCommandArgs {
/// Pass flag to remove all artifacts
#[arg(short = 'a', long)]
#[arg(short, long)]
pub(crate) all: bool,
}

Expand All @@ -40,7 +40,7 @@
pub(crate) all: bool,
}

impl<'a, CLI: Cli> CleanCacheCommand<'a, CLI> {

Check warning on line 43 in crates/pop-cli/src/commands/clean.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'a

warning: the following explicit lifetimes could be elided: 'a --> crates/pop-cli/src/commands/clean.rs:43:6 | 43 | impl<'a, CLI: Cli> CleanCacheCommand<'a, CLI> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes = note: `#[warn(clippy::needless_lifetimes)]` on by default help: elide the lifetimes | 43 - impl<'a, CLI: Cli> CleanCacheCommand<'a, CLI> { 43 + impl<CLI: Cli> CleanCacheCommand<'_, CLI> { |
/// Executes the command.
pub(crate) fn execute(self) -> Result<()> {
self.cli.intro("Remove cached artifacts")?;
Expand Down
2 changes: 1 addition & 1 deletion crates/pop-cli/src/commands/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub enum Dependencies {
#[command(args_conflicts_with_subcommands = true)]
pub(crate) struct InstallArgs {
/// Automatically install all dependencies required without prompting for confirmation.
#[clap(short('y'), long)]
#[clap(short = 'y', long)]
skip_confirm: bool,
}

Expand Down
8 changes: 2 additions & 6 deletions crates/pop-cli/src/commands/new/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ pub struct NewContractCommand {
/// The type of contract.
#[arg(
default_value = ContractType::Examples.as_ref(),
short = 'c',
short,
long,
value_parser = enum_variants!(ContractType)
)]
pub(crate) contract_type: Option<ContractType>,
/// The template to use.
#[arg(
short = 't',
long,
value_parser = enum_variants!(Contract)
)]
#[arg(short, long, value_parser = enum_variants!(Contract))]
pub(crate) template: Option<Contract>,
}

Expand Down
14 changes: 5 additions & 9 deletions crates/pop-cli/src/commands/test/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,18 @@ use {std::time::Duration, tokio::time::sleep};

#[derive(Args)]
pub(crate) struct TestContractCommand {
#[arg(short = 'p', long, help = "Path for the contract project [default: current directory]")]
#[arg(short, long, help = "Path for the contract project [default: current directory]")]
path: Option<PathBuf>,
/// [DEPRECATED] Run e2e tests
#[arg(short = 'f', long = "features", value_parser=["e2e-tests"])]
#[arg(short, long, value_parser=["e2e-tests"])]
features: Option<String>,
/// Run end-to-end tests
#[arg(short = 'e', long = "e2e")]
#[arg(short, long)]
e2e: bool,
#[arg(
short = 'n',
long = "node",
help = "Path to the contracts node to run e2e tests [default: none]"
)]
#[arg(short, long, help = "Path to the contracts node to run e2e tests [default: none]")]
node: Option<PathBuf>,
/// Automatically source the needed binary required without prompting for confirmation.
#[clap(short('y'), long)]
#[clap(short = 'y', long)]
skip_confirm: bool,
}

Expand Down
24 changes: 12 additions & 12 deletions crates/pop-cli/src/commands/up/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,49 @@ const FAILED: &str = "🚫 Deployment failed.";
#[derive(Args, Clone)]
pub struct UpContractCommand {
/// Path to the contract build directory.
#[arg(short = 'p', long)]
#[arg(short, long)]
path: Option<PathBuf>,
/// The name of the contract constructor to call.
#[clap(name = "constructor", long, default_value = "new")]
#[clap(short, long, default_value = "new")]
constructor: String,
/// The constructor arguments, encoded as strings.
#[clap(long, num_args = 0..,)]
#[clap(short, long, num_args = 0..,)]
args: Vec<String>,
/// Transfers an initial balance to the instantiated contract.
#[clap(name = "value", long, default_value = "0")]
#[clap(short, long, default_value = "0")]
value: String,
/// Maximum amount of gas to be used for this command.
/// If not specified it will perform a dry-run to estimate the gas consumed for the
/// instantiation.
#[clap(name = "gas", long)]
#[clap(name = "gas", short, long)]
gas_limit: Option<u64>,
/// Maximum proof size for the instantiation.
/// If not specified it will perform a dry-run to estimate the proof size required.
#[clap(long)]
#[clap(short = 'P', long)]
proof_size: Option<u64>,
/// A salt used in the address derivation of the new contract. Use to create multiple
/// instances of the same contract code from the same account.
#[clap(long, value_parser = parse_hex_bytes)]
#[clap(short = 'S', long, value_parser = parse_hex_bytes)]
salt: Option<Bytes>,
/// Websocket endpoint of a chain.
#[clap(name = "url", long, value_parser, default_value = DEFAULT_URL)]
#[clap(short, long, value_parser, default_value = DEFAULT_URL)]
url: Url,
/// Secret key URI for the account deploying the contract.
///
/// e.g.
/// - for a dev account "//Alice"
/// - with a password "//Alice///SECRET_PASSWORD"
#[clap(name = "suri", long, short, default_value = "//Alice")]
#[clap(short, long, default_value = "//Alice")]
suri: String,
/// Perform a dry-run via RPC to estimate the gas usage. This does not submit a transaction.
#[clap(long)]
#[clap(short = 'D', long)]
dry_run: bool,
/// Uploads the contract only, without instantiation.
#[clap(short('u'), long)]
#[clap(short = 'U', long)]
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
upload_only: bool,
/// Automatically source or update the needed binary required without prompting for
/// confirmation.
#[clap(short('y'), long)]
#[clap(short = 'y', long)]
skip_confirm: bool,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/pop-cli/src/commands/up/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
#[arg(short, long)]
parachain: Option<Vec<String>>,
/// The command to run after the network has been launched.
#[clap(name = "cmd", short = 'c', long)]
#[clap(name = "cmd", short, long)]
command: Option<String>,
/// Whether the output should be verbose.
#[arg(short, long, action)]
verbose: bool,
/// Automatically source all needed binaries required without prompting for confirmation.
#[clap(short('y'), long)]
#[clap(short = 'y', long)]
skip_confirm: bool,
}

Expand Down Expand Up @@ -255,7 +255,7 @@
let binaries: Vec<_> = binaries
.into_iter()
.filter(|b| !b.exists() || (latest && b.stale()))
.map(|b| {

Check warning on line 258 in crates/pop-cli/src/commands/up/parachain.rs

View workflow job for this annotation

GitHub Actions / clippy

using `map` over `inspect`

warning: using `map` over `inspect` --> crates/pop-cli/src/commands/up/parachain.rs:258:5 | 258 | .map(|b| { | ^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect = note: `#[warn(clippy::manual_inspect)]` on by default help: try | 258 ~ .inspect(|b| { 259 | if latest && b.stale() { 260 | b.use_latest() 261 ~ } |
if latest && b.stale() {
b.use_latest()
}
Expand Down
Loading