diff --git a/src/cli/shell.rs b/src/cli/shell.rs index a0eb49482..386657d91 100644 --- a/src/cli/shell.rs +++ b/src/cli/shell.rs @@ -220,15 +220,15 @@ pub async fn execute(args: Args) -> miette::Result<()> { #[cfg(target_family = "windows")] let res = match interactive_shell { ShellEnum::NuShell(nushell) => { - start_nu_shell(nushell, &env, prompt::get_nu_prompt(prompt_name.as_str())).await + start_nu_shell(nushell, env, prompt::get_nu_prompt(prompt_name.as_str())).await } ShellEnum::PowerShell(pwsh) => start_powershell( pwsh, - &env, + env, prompt::get_powershell_prompt(prompt_name.as_str()), ), ShellEnum::CmdExe(cmdexe) => { - start_cmdexe(cmdexe, &env, prompt::get_cmd_prompt(prompt_name.as_str())) + start_cmdexe(cmdexe, env, prompt::get_cmd_prompt(prompt_name.as_str())) } _ => { miette::bail!("Unsupported shell: {:?}", interactive_shell); diff --git a/src/project/mod.rs b/src/project/mod.rs index b33227161..f25aa5a17 100644 --- a/src/project/mod.rs +++ b/src/project/mod.rs @@ -116,10 +116,7 @@ impl Debug for Project { impl Project { /// Constructs a new instance from an internal manifest representation pub fn from_manifest(manifest: Manifest) -> Self { - let client = reqwest::Client::new(); - let authenticated_client = reqwest_middleware::ClientBuilder::new(reqwest::Client::new()) - .with_arc(Arc::new(AuthenticationMiddleware::default())) - .build(); + let (client, authenticated_client) = build_reqwest_clients(); let env_vars = Project::init_env_vars(&manifest.parsed.environments); @@ -191,16 +188,7 @@ impl Project { let env_vars = Project::init_env_vars(&manifest.parsed.environments); - let timeout = 5 * 60; - let client = Client::builder() - .pool_max_idle_per_host(20) - .timeout(std::time::Duration::from_secs(timeout)) - .build() - .expect("failed to create reqwest Client"); - - let authenticated_client = reqwest_middleware::ClientBuilder::new(client.clone()) - .with_arc(Arc::new(AuthenticationMiddleware::default())) - .build(); + let (client, authenticated_client) = build_reqwest_clients(); Ok(Self { root: root.to_owned(), @@ -471,6 +459,24 @@ impl Project { } } +fn build_reqwest_clients() -> (Client, ClientWithMiddleware) { + static APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); + + let timeout = 5 * 60; + let client = Client::builder() + .pool_max_idle_per_host(20) + .user_agent(APP_USER_AGENT) + .timeout(std::time::Duration::from_secs(timeout)) + .build() + .expect("failed to create reqwest Client"); + + let authenticated_client = reqwest_middleware::ClientBuilder::new(client.clone()) + .with_arc(Arc::new(AuthenticationMiddleware::default())) + .build(); + + (client, authenticated_client) +} + /// Iterates over the current directory and all its parent directories and returns the first /// directory path that contains the [`consts::PROJECT_MANIFEST`]. pub fn find_project_root() -> Option {