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

fix: parse env name on adding #2279

Merged
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
8 changes: 3 additions & 5 deletions src/cli/project/environment/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use pixi_manifest::EnvironmentName;
#[derive(Parser, Debug)]
pub struct Args {
/// The name of the environment to add.
pub name: String,
pub name: EnvironmentName,

/// Features to add to the environment.
#[arg(short, long = "feature")]
Expand All @@ -25,9 +25,7 @@ pub struct Args {
}

pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> {
let environment_exists = project
.environment(&EnvironmentName::Named(args.name.clone()))
.is_some();
let environment_exists = project.environment(&args.name).is_some();
if environment_exists && !args.force {
return Err(miette::miette!(
help = "use --force to overwrite the existing environment",
Expand All @@ -38,7 +36,7 @@ pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> {

// Add the platforms to the lock-file
project.manifest.add_environment(
args.name.clone(),
args.name.as_str().to_string(),
args.features,
args.solve_group,
args.no_default_feature,
Expand Down
4 changes: 2 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ impl PixiControl {
}
}

pub fn project_environment_add(&self, name: &str) -> ProjectEnvironmentAddBuilder {
pub fn project_environment_add(&self, name: EnvironmentName) -> ProjectEnvironmentAddBuilder {
ProjectEnvironmentAddBuilder {
manifest_path: Some(self.manifest_path()),
args: project::environment::add::Args {
name: name.to_string(),
name,
features: None,
solve_group: None,
no_default_feature: false,
Expand Down
Loading