Skip to content

Commit

Permalink
Merge pull request #28400 from ProvableHQ/rename-arggroups
Browse files Browse the repository at this point in the history
Fixes to clap CLI code.
  • Loading branch information
d0cd authored Oct 17, 2024
2 parents 00fcc07 + 1f900bc commit 76b8654
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 111 deletions.
68 changes: 36 additions & 32 deletions leo/cli/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum Commands {
#[clap(about = "Create a new Leo package in a new directory")]
New {
#[clap(flatten)]
command: New,
command: LeoNew,
},
#[clap(about = "Create a new Leo example package in a new directory")]
Example {
Expand All @@ -60,12 +60,12 @@ enum Commands {
#[clap(about = "Run a program with input variables")]
Run {
#[clap(flatten)]
command: Run,
command: LeoRun,
},
#[clap(about = "Execute a program with input variables")]
Execute {
#[clap(flatten)]
command: Execute,
command: LeoExecute,
},
#[clap(about = "Deploy a program")]
Deploy {
Expand All @@ -75,32 +75,32 @@ enum Commands {
#[clap(about = "Query live data from the Aleo network")]
Query {
#[clap(flatten)]
command: Query,
command: LeoQuery,
},
#[clap(about = "Compile the current package as a program")]
Build {
#[clap(flatten)]
command: Build,
command: LeoBuild,
},
#[clap(about = "Add a new on-chain or local dependency to the current package.")]
Add {
#[clap(flatten)]
command: Add,
command: LeoAdd,
},
#[clap(about = "Remove a dependency from the current package.")]
Remove {
#[clap(flatten)]
command: Remove,
command: LeoRemove,
},
#[clap(about = "Clean the output directory")]
Clean {
#[clap(flatten)]
command: Clean,
command: LeoClean,
},
#[clap(about = "Update the Leo CLI")]
Update {
#[clap(flatten)]
command: Update,
command: LeoUpdate,
},
}

Expand Down Expand Up @@ -169,7 +169,7 @@ mod tests {
debug: false,
quiet: false,
command: Commands::Run {
command: crate::cli::commands::Run {
command: crate::cli::commands::LeoRun {
name: "example".to_string(),
inputs: vec!["1u32".to_string(), "2u32".to_string()],
file: None,
Expand Down Expand Up @@ -211,7 +211,7 @@ mod tests {
debug: false,
quiet: false,
command: Commands::Run {
command: crate::cli::commands::Run {
command: crate::cli::commands::LeoRun {
name: "double_wrapper_mint".to_string(),
inputs: vec![
"aleo13tngrq7506zwdxj0cxjtvp28pk937jejhne0rt4zp0z370uezuysjz2prs".to_string(),
Expand Down Expand Up @@ -254,7 +254,7 @@ mod tests {
debug: false,
quiet: false,
command: Commands::Run {
command: crate::cli::commands::Run {
command: crate::cli::commands::LeoRun {
name: "inner_1_main".to_string(),
inputs: vec!["1u32".to_string(), "2u32".to_string()],
compiler_options: Default::default(),
Expand Down Expand Up @@ -291,7 +291,7 @@ mod tests {
debug: false,
quiet: false,
command: Commands::Run {
command: crate::cli::commands::Run {
command: crate::cli::commands::LeoRun {
name: "main".to_string(),
inputs: vec!["1u32".to_string(), "2u32".to_string()],
compiler_options: Default::default(),
Expand All @@ -310,7 +310,7 @@ mod tests {

#[cfg(test)]
mod test_helpers {
use crate::cli::{Add, CLI, New, cli::Commands, run_with_args};
use crate::cli::{CLI, LeoAdd, LeoNew, cli::Commands, run_with_args};
use leo_span::symbol::create_session_if_not_set_then;
use std::path::Path;

Expand All @@ -331,7 +331,11 @@ mod test_helpers {
debug: false,
quiet: false,
command: Commands::New {
command: New { name: name.to_string(), network: NETWORK.to_string(), endpoint: ENDPOINT.to_string() },
command: LeoNew {
name: name.to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
},
},
path: Some(project_directory.clone()),
home: None,
Expand Down Expand Up @@ -397,7 +401,7 @@ function external_nested_function:
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "nested_example_layer_0".to_string(),
local: None,
network: NETWORK.to_string(),
Expand Down Expand Up @@ -434,7 +438,7 @@ function external_nested_function:
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "grandparent".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand All @@ -448,7 +452,7 @@ function external_nested_function:
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "parent".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand All @@ -462,7 +466,7 @@ function external_nested_function:
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "child".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand Down Expand Up @@ -509,7 +513,7 @@ program child.aleo {
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "parent".to_string(),
local: Some(parent_directory.clone()),
network: NETWORK.to_string(),
Expand All @@ -524,7 +528,7 @@ program child.aleo {
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "child".to_string(),
local: Some(child_directory.clone()),
network: NETWORK.to_string(),
Expand All @@ -539,7 +543,7 @@ program child.aleo {
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "child".to_string(),
local: Some(child_directory.clone()),
network: NETWORK.to_string(),
Expand Down Expand Up @@ -583,7 +587,7 @@ program child.aleo {
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "outer".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand All @@ -597,7 +601,7 @@ program child.aleo {
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "inner_1".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand All @@ -611,7 +615,7 @@ program child.aleo {
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "inner_2".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand Down Expand Up @@ -681,7 +685,7 @@ program outer.aleo {
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "inner_1".to_string(),
local: Some(inner_1_directory.clone()),
network: NETWORK.to_string(),
Expand All @@ -696,7 +700,7 @@ program outer.aleo {
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "inner_2".to_string(),
local: Some(inner_2_directory.clone()),
network: NETWORK.to_string(),
Expand Down Expand Up @@ -739,7 +743,7 @@ program outer.aleo {
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "outer_2".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand All @@ -753,7 +757,7 @@ program outer.aleo {
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "inner_1".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand All @@ -767,7 +771,7 @@ program outer.aleo {
debug: false,
quiet: false,
command: Commands::New {
command: New {
command: LeoNew {
name: "inner_2".to_string(),
network: NETWORK.to_string(),
endpoint: ENDPOINT.to_string(),
Expand Down Expand Up @@ -868,7 +872,7 @@ program outer_2.aleo {
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "inner_1".to_string(),
local: Some(inner_1_directory.clone()),
network: NETWORK.to_string(),
Expand All @@ -883,7 +887,7 @@ program outer_2.aleo {
debug: false,
quiet: false,
command: Commands::Add {
command: Add {
command: LeoAdd {
name: "inner_2".to_string(),
local: Some(inner_2_directory.clone()),
network: NETWORK.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions leo/cli/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::path::PathBuf;
/// Add a new on-chain or local dependency to the current package.
#[derive(Parser, Debug)]
#[clap(name = "leo", author = "The Leo Team <[email protected]>", version)]
pub struct Add {
pub struct LeoAdd {
#[clap(name = "NAME", help = "The dependency name. Ex: `credits.aleo` or `credits`.")]
pub(crate) name: String,

Expand All @@ -35,7 +35,7 @@ pub struct Add {
pub(crate) clear: bool,
}

impl Command for Add {
impl Command for LeoAdd {
type Input = ();
type Output = ();

Expand Down
6 changes: 3 additions & 3 deletions leo/cli/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ impl From<BuildOptions> for CompilerOptions {

/// Compile and build program command.
#[derive(Parser, Debug)]
pub struct Build {
pub struct LeoBuild {
#[clap(flatten)]
pub(crate) options: BuildOptions,
}

impl Command for Build {
impl Command for LeoBuild {
type Input = ();
type Output = ();

Expand All @@ -104,7 +104,7 @@ impl Command for Build {
}

// A helper function to handle the build command.
fn handle_build<N: Network>(command: &Build, context: Context) -> Result<<Build as Command>::Output> {
fn handle_build<N: Network>(command: &LeoBuild, context: Context) -> Result<<LeoBuild as Command>::Output> {
// Get the package path.
let package_path = context.dir()?;
let home_path = context.home()?;
Expand Down
4 changes: 2 additions & 2 deletions leo/cli/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use super::*;

/// Clean outputs folder command
#[derive(Parser, Debug)]
pub struct Clean {}
pub struct LeoClean {}

impl Command for Clean {
impl Command for LeoClean {
type Input = ();
type Output = ();

Expand Down
2 changes: 1 addition & 1 deletion leo/cli/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Command for Deploy {

fn prelude(&self, context: Context) -> Result<Self::Input> {
if !self.no_build {
(Build { options: self.options.clone() }).execute(context)?;
(LeoBuild { options: self.options.clone() }).execute(context)?;
}
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions leo/cli/commands/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ pub struct Example {
}

impl Command for Example {
type Input = <New as Command>::Output;
type Input = <LeoNew as Command>::Output;
type Output = ();

fn prelude(&self, context: Context) -> Result<Self::Input> {
// Run leo new <name> --network <network>
(New { name: self.name.clone(), network: self.network.clone(), endpoint: self.endpoint.clone() })
(LeoNew { name: self.name.clone(), network: self.network.clone(), endpoint: self.endpoint.clone() })
.execute(context)
}

Expand Down
Loading

0 comments on commit 76b8654

Please sign in to comment.