From 47b77183e442dc09ce858b4bbdb93dfa2172d674 Mon Sep 17 00:00:00 2001 From: Brandon Maier Date: Mon, 16 Dec 2024 12:32:49 -0600 Subject: [PATCH] feat: replace custom manifest_path with ProjectConfig helper --- src/cli/project/description/mod.rs | 10 ++++------ src/cli/project/environment/mod.rs | 10 ++++------ src/cli/project/platform/mod.rs | 10 ++++------ src/cli/project/version/mod.rs | 10 ++++------ tests/integration_rust/common/builders.rs | 4 +++- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/cli/project/description/mod.rs b/src/cli/project/description/mod.rs index 11e5dc966..0885c09a0 100644 --- a/src/cli/project/description/mod.rs +++ b/src/cli/project/description/mod.rs @@ -1,16 +1,14 @@ pub mod get; pub mod set; -use crate::Project; +use crate::{cli::cli_config::ProjectConfig, Project}; use clap::Parser; -use std::path::PathBuf; /// Commands to manage project description. #[derive(Parser, Debug)] pub struct Args { - /// The path to `pixi.toml` or `pyproject.toml` - #[clap(long, global = true)] - pub manifest_path: Option, + #[clap(flatten)] + pub project_config: ProjectConfig, /// The subcommand to execute #[clap(subcommand)] @@ -26,7 +24,7 @@ pub enum Command { } pub async fn execute(args: Args) -> miette::Result<()> { - let project = Project::load_or_else_discover(args.manifest_path.as_deref())?; + let project = Project::load_or_else_discover(args.project_config.manifest_path.as_deref())?; match args.command { Command::Get => get::execute(project).await?, diff --git a/src/cli/project/environment/mod.rs b/src/cli/project/environment/mod.rs index 3d51dd280..8024098c2 100644 --- a/src/cli/project/environment/mod.rs +++ b/src/cli/project/environment/mod.rs @@ -2,16 +2,14 @@ pub mod add; pub mod list; pub mod remove; -use crate::Project; +use crate::{cli::cli_config::ProjectConfig, Project}; use clap::Parser; -use std::path::PathBuf; /// Commands to manage project environments. #[derive(Parser, Debug)] pub struct Args { - /// The path to `pixi.toml` or `pyproject.toml` - #[clap(long, global = true)] - pub manifest_path: Option, + #[clap(flatten)] + pub project_config: ProjectConfig, /// The subcommand to execute #[clap(subcommand)] @@ -32,7 +30,7 @@ pub enum Command { } pub async fn execute(args: Args) -> miette::Result<()> { - let project = Project::load_or_else_discover(args.manifest_path.as_deref())?; + let project = Project::load_or_else_discover(args.project_config.manifest_path.as_deref())?; match args.command { Command::Add(args) => add::execute(project, args).await, diff --git a/src/cli/project/platform/mod.rs b/src/cli/project/platform/mod.rs index 230900bc1..23d92a698 100644 --- a/src/cli/project/platform/mod.rs +++ b/src/cli/project/platform/mod.rs @@ -2,16 +2,14 @@ pub mod add; pub mod list; pub mod remove; -use crate::Project; +use crate::{cli::cli_config::ProjectConfig, Project}; use clap::Parser; -use std::path::PathBuf; /// Commands to manage project platforms. #[derive(Parser, Debug)] pub struct Args { - /// The path to `pixi.toml` or `pyproject.toml` - #[clap(long, global = true)] - pub manifest_path: Option, + #[clap(flatten)] + pub project_config: ProjectConfig, /// The subcommand to execute #[clap(subcommand)] @@ -32,7 +30,7 @@ pub enum Command { } pub async fn execute(args: Args) -> miette::Result<()> { - let project = Project::load_or_else_discover(args.manifest_path.as_deref())?; + let project = Project::load_or_else_discover(args.project_config.manifest_path.as_deref())?; match args.command { Command::Add(args) => add::execute(project, args).await, diff --git a/src/cli/project/version/mod.rs b/src/cli/project/version/mod.rs index c72f99694..255e26985 100644 --- a/src/cli/project/version/mod.rs +++ b/src/cli/project/version/mod.rs @@ -2,17 +2,15 @@ pub mod bump; pub mod get; pub mod set; -use crate::Project; +use crate::{cli::cli_config::ProjectConfig, Project}; use clap::Parser; use rattler_conda_types::VersionBumpType; -use std::path::PathBuf; /// Commands to manage project version. #[derive(Parser, Debug)] pub struct Args { - /// The path to `pixi.toml` or `pyproject.toml` - #[clap(long, global = true)] - pub manifest_path: Option, + #[clap(flatten)] + pub project_config: ProjectConfig, /// The subcommand to execute #[clap(subcommand)] @@ -34,7 +32,7 @@ pub enum Command { } pub async fn execute(args: Args) -> miette::Result<()> { - let project = Project::load_or_else_discover(args.manifest_path.as_deref())?; + let project = Project::load_or_else_discover(args.project_config.manifest_path.as_deref())?; match args.command { Command::Get(args) => get::execute(project, args).await?, diff --git a/tests/integration_rust/common/builders.rs b/tests/integration_rust/common/builders.rs index b455280d6..7ed0a54ab 100644 --- a/tests/integration_rust/common/builders.rs +++ b/tests/integration_rust/common/builders.rs @@ -458,7 +458,9 @@ impl IntoFuture for ProjectEnvironmentAddBuilder { type IntoFuture = Pin + 'static>>; fn into_future(self) -> Self::IntoFuture { project::environment::execute(project::environment::Args { - manifest_path: self.manifest_path, + project_config: ProjectConfig { + manifest_path: self.manifest_path, + }, command: project::environment::Command::Add(self.args), }) .boxed_local()