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: align shell-hook cli with shell #1364

Merged
merged 1 commit into from
May 10, 2024
Merged
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
16 changes: 8 additions & 8 deletions src/cli/shell_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ use serde_json;
use std::collections::HashMap;
use std::{default::Default, path::PathBuf};

use crate::config::ConfigCliPrompt;
use crate::{
activation::get_activator,
cli::LockFileUsageArgs,
environment::get_up_to_date_prefix,
project::{has_features::HasFeatures, manifest::EnvironmentName, Environment},
project::{has_features::HasFeatures, Environment},
Project,
};

Expand All @@ -39,6 +40,9 @@ pub struct Args {
/// Emit the environment variables set by running the activation as JSON
#[clap(long, default_value = "false", conflicts_with = "shell")]
json: bool,

#[clap(flatten)]
config: ConfigCliPrompt,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -88,13 +92,9 @@ async fn generate_environment_json(environment: &Environment<'_>) -> miette::Res

/// Prints the activation script to the stdout.
pub async fn execute(args: Args) -> miette::Result<()> {
let project = Project::load_or_else_discover(args.manifest_path.as_deref())?;
let environment_name = args
.environment
.map_or_else(|| EnvironmentName::Default, EnvironmentName::Named);
let environment = project
.environment(&environment_name)
.ok_or_else(|| miette::miette!("unknown environment '{environment_name}'"))?;
let project =
Project::load_or_else_discover(args.manifest_path.as_deref())?.with_cli_config(args.config);
let environment = project.environment_from_name_or_env_var(args.environment)?;

get_up_to_date_prefix(
&environment,
Expand Down
Loading