Skip to content

Commit

Permalink
feat: replace custom manifest_path with ProjectConfig helper
Browse files Browse the repository at this point in the history
  • Loading branch information
blmaier committed Dec 16, 2024
1 parent cb5c837 commit 47b7718
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
10 changes: 4 additions & 6 deletions src/cli/project/description/mod.rs
Original file line number Diff line number Diff line change
@@ -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<PathBuf>,
#[clap(flatten)]
pub project_config: ProjectConfig,

/// The subcommand to execute
#[clap(subcommand)]
Expand All @@ -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?,
Expand Down
10 changes: 4 additions & 6 deletions src/cli/project/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
#[clap(flatten)]
pub project_config: ProjectConfig,

/// The subcommand to execute
#[clap(subcommand)]
Expand All @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions src/cli/project/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
#[clap(flatten)]
pub project_config: ProjectConfig,

/// The subcommand to execute
#[clap(subcommand)]
Expand All @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions src/cli/project/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
#[clap(flatten)]
pub project_config: ProjectConfig,

/// The subcommand to execute
#[clap(subcommand)]
Expand All @@ -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?,
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_rust/common/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ impl IntoFuture for ProjectEnvironmentAddBuilder {
type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + '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()
Expand Down

0 comments on commit 47b7718

Please sign in to comment.