aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mozart/src')
-rw-r--r--crates/mozart/src/commands.rs14
-rw-r--r--crates/mozart/src/commands/archive.rs5
-rw-r--r--crates/mozart/src/commands/audit.rs8
-rw-r--r--crates/mozart/src/commands/browse.rs7
-rw-r--r--crates/mozart/src/commands/bump.rs6
-rw-r--r--crates/mozart/src/commands/check_platform_reqs.rs7
-rw-r--r--crates/mozart/src/commands/config.rs9
-rw-r--r--crates/mozart/src/commands/config_helpers.rs10
-rw-r--r--crates/mozart/src/commands/create_project.rs2
-rw-r--r--crates/mozart/src/commands/dependency.rs7
-rw-r--r--crates/mozart/src/commands/diagnose.rs5
-rw-r--r--crates/mozart/src/commands/dump_autoload.rs6
-rw-r--r--crates/mozart/src/commands/exec.rs5
-rw-r--r--crates/mozart/src/commands/fund.rs7
-rw-r--r--crates/mozart/src/commands/init.rs7
-rw-r--r--crates/mozart/src/commands/install.rs12
-rw-r--r--crates/mozart/src/commands/licenses.rs7
-rw-r--r--crates/mozart/src/commands/outdated.rs7
-rw-r--r--crates/mozart/src/commands/reinstall.rs7
-rw-r--r--crates/mozart/src/commands/remove.rs3
-rw-r--r--crates/mozart/src/commands/repository.rs5
-rw-r--r--crates/mozart/src/commands/require.rs5
-rw-r--r--crates/mozart/src/commands/run_script.rs5
-rw-r--r--crates/mozart/src/commands/show.rs7
-rw-r--r--crates/mozart/src/commands/status.rs5
-rw-r--r--crates/mozart/src/commands/suggests.rs7
-rw-r--r--crates/mozart/src/commands/update.rs2
-rw-r--r--crates/mozart/src/commands/validate.rs5
28 files changed, 56 insertions, 126 deletions
diff --git a/crates/mozart/src/commands.rs b/crates/mozart/src/commands.rs
index 504e38d..44ca07d 100644
--- a/crates/mozart/src/commands.rs
+++ b/crates/mozart/src/commands.rs
@@ -62,7 +62,7 @@ pub struct Cli {
/// If specified, use the given directory as working directory
#[arg(short = 'd', long = "working-dir", global = true)]
- pub working_dir: Option<String>,
+ working_dir: Option<String>,
/// Prevent use of the cache
#[arg(long, global = true)]
@@ -85,6 +85,18 @@ pub struct Cli {
pub no_ansi: bool,
}
+impl Cli {
+ /// Resolve the working directory: returns `--working-dir` if set, otherwise
+ /// the current working directory.
+ pub fn working_dir(&self) -> anyhow::Result<std::path::PathBuf> {
+ match &self.working_dir {
+ Some(dir) => Ok(std::path::PathBuf::from(dir)),
+ None => std::env::current_dir()
+ .map_err(|e| anyhow::anyhow!("Failed to get current directory: {}", e)),
+ }
+ }
+}
+
#[derive(clap::Subcommand)]
pub enum Commands {
/// Shows a short information about Mozart
diff --git a/crates/mozart/src/commands/archive.rs b/crates/mozart/src/commands/archive.rs
index ca57259..eea62d1 100644
--- a/crates/mozart/src/commands/archive.rs
+++ b/crates/mozart/src/commands/archive.rs
@@ -99,10 +99,7 @@ pub async fn execute(
let files_cache = mozart_registry::cache::Cache::files(&cache_config);
// 1. Determine working directory
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// 2. Load Composer state for format/dir defaults. Composer's
// `archive` command falls back to `Factory::createConfig()` when no
diff --git a/crates/mozart/src/commands/audit.rs b/crates/mozart/src/commands/audit.rs
index 163a43a..881a54f 100644
--- a/crates/mozart/src/commands/audit.rs
+++ b/crates/mozart/src/commands/audit.rs
@@ -1,6 +1,6 @@
use clap::Args;
use std::collections::BTreeMap;
-use std::path::{Path, PathBuf};
+use std::path::Path;
use mozart_core::console::Verbosity;
use mozart_registry::packagist::SecurityAdvisory;
@@ -94,11 +94,7 @@ pub async fn execute(
),
};
- // Determine working directory
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// Load packages
let packages = load_packages(&working_dir, args.locked, args.no_dev)?;
diff --git a/crates/mozart/src/commands/browse.rs b/crates/mozart/src/commands/browse.rs
index 24fc46f..7ee1858 100644
--- a/crates/mozart/src/commands/browse.rs
+++ b/crates/mozart/src/commands/browse.rs
@@ -1,7 +1,7 @@
use clap::Args;
use mozart_core::console_format;
use mozart_core::exit_code;
-use std::path::{Path, PathBuf};
+use std::path::Path;
use std::process::Command;
#[derive(Args)]
@@ -28,10 +28,7 @@ pub async fn execute(
let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache);
let repo_cache = mozart_registry::cache::Cache::repo(&cache_config);
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// If no packages specified, use root package name from composer.json
let packages: Vec<String> = if args.packages.is_empty() {
diff --git a/crates/mozart/src/commands/bump.rs b/crates/mozart/src/commands/bump.rs
index 3ad6ed6..72c34a1 100644
--- a/crates/mozart/src/commands/bump.rs
+++ b/crates/mozart/src/commands/bump.rs
@@ -2,7 +2,6 @@ use clap::Args;
use indexmap::IndexMap;
use mozart_core::console::Verbosity;
use mozart_core::console_format;
-use std::path::PathBuf;
/// Exit code for stale lock file (matches Composer's BumpCommand::ERROR_LOCK_OUTDATED)
const ERROR_LOCK_OUTDATED: i32 = 2;
@@ -32,10 +31,7 @@ pub async fn execute(
cli: &super::Cli,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
let composer_json_path = working_dir.join("composer.json");
let lock_path = working_dir.join("composer.lock");
diff --git a/crates/mozart/src/commands/check_platform_reqs.rs b/crates/mozart/src/commands/check_platform_reqs.rs
index a890e0c..e3d432a 100644
--- a/crates/mozart/src/commands/check_platform_reqs.rs
+++ b/crates/mozart/src/commands/check_platform_reqs.rs
@@ -1,7 +1,7 @@
use clap::Args;
use mozart_core::console::{Console, Verbosity};
use std::collections::BTreeMap;
-use std::path::{Path, PathBuf};
+use std::path::Path;
#[derive(Args)]
pub struct CheckPlatformReqsArgs {
@@ -58,10 +58,7 @@ pub async fn execute(
cli: &super::Cli,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// Validate format
let format = args.format.as_deref().unwrap_or("text");
diff --git a/crates/mozart/src/commands/config.rs b/crates/mozart/src/commands/config.rs
index 11b1b7b..1946264 100644
--- a/crates/mozart/src/commands/config.rs
+++ b/crates/mozart/src/commands/config.rs
@@ -4,8 +4,7 @@ use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use super::config_helpers::{
- add_repository, composer_home, read_json_file, remove_repository, render_value, working_dir,
- write_json_file,
+ add_repository, composer_home, read_json_file, remove_repository, render_value, write_json_file,
};
#[derive(Args)]
@@ -354,7 +353,7 @@ fn resolve_config_file_path(args: &ConfigArgs, cli: &super::Cli) -> anyhow::Resu
if let Some(ref file) = args.file {
return Ok(PathBuf::from(file));
}
- Ok(working_dir(cli)?.join("composer.json"))
+ Ok(cli.working_dir()?.join("composer.json"))
}
// ─── Helpers ──────────────────────────────────────────────────────────────────
@@ -788,7 +787,7 @@ fn execute_read(
let overrides = load_config_section(&global_config_path)?;
config.merge(&overrides);
} else {
- let wd = working_dir(cli)?;
+ let wd = cli.working_dir()?;
let composer_json = wd.join("composer.json");
let overrides = load_config_section(&composer_json)?;
config.merge(&overrides);
@@ -798,7 +797,7 @@ fn execute_read(
// If --absolute is requested, resolve *-dir values to absolute paths.
if args.absolute {
- let wd = working_dir(cli)?;
+ let wd = cli.working_dir()?;
let keys: Vec<String> = config.values.keys().cloned().collect();
for key in keys {
if key.ends_with("-dir")
diff --git a/crates/mozart/src/commands/config_helpers.rs b/crates/mozart/src/commands/config_helpers.rs
index 2f856a7..c5cd187 100644
--- a/crates/mozart/src/commands/config_helpers.rs
+++ b/crates/mozart/src/commands/config_helpers.rs
@@ -3,14 +3,6 @@ use std::path::{Path, PathBuf};
pub(crate) use mozart_core::composer::composer_home;
-/// Build the working directory path, preferring `--working-dir` over `cwd`.
-pub(crate) fn working_dir(cli: &super::Cli) -> anyhow::Result<PathBuf> {
- match &cli.working_dir {
- Some(d) => Ok(PathBuf::from(d)),
- None => Ok(std::env::current_dir()?),
- }
-}
-
/// Read TLS-related options (`config.cafile`, `config.capath`) from the merged
/// global + local config. Local values override global. Relative paths are
/// resolved against the directory of the config file that defined them.
@@ -20,7 +12,7 @@ pub(crate) fn load_tls_options(cli: &super::Cli) -> mozart_core::http::TlsOption
let home = composer_home();
apply_tls_from_file(&home.join("config.json"), &home, &mut opts);
- if let Ok(wd) = working_dir(cli) {
+ if let Ok(wd) = cli.working_dir() {
apply_tls_from_file(&wd.join("composer.json"), &wd, &mut opts);
}
diff --git a/crates/mozart/src/commands/create_project.rs b/crates/mozart/src/commands/create_project.rs
index 6674ccc..5461418 100644
--- a/crates/mozart/src/commands/create_project.rs
+++ b/crates/mozart/src/commands/create_project.rs
@@ -227,7 +227,7 @@ pub async fn execute(
let version_constraint: Option<String> = version_from_arg.or_else(|| args.version.clone());
// --- Step 2: Determine target directory ---
- let working_dir = super::install::resolve_working_dir(cli);
+ let working_dir = cli.working_dir()?;
let target_dir: PathBuf = {
let dir_name = args
diff --git a/crates/mozart/src/commands/dependency.rs b/crates/mozart/src/commands/dependency.rs
index 19e9430..4e24f1d 100644
--- a/crates/mozart/src/commands/dependency.rs
+++ b/crates/mozart/src/commands/dependency.rs
@@ -6,7 +6,7 @@
use indexmap::IndexSet;
use std::collections::BTreeMap;
-use std::path::{Path, PathBuf};
+use std::path::Path;
use anyhow::Result;
use mozart_core::console_format;
@@ -46,10 +46,7 @@ pub fn do_execute(
inverted,
} = args;
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
let packages = load_packages(&working_dir, locked)?;
diff --git a/crates/mozart/src/commands/diagnose.rs b/crates/mozart/src/commands/diagnose.rs
index 54296ce..382b8ae 100644
--- a/crates/mozart/src/commands/diagnose.rs
+++ b/crates/mozart/src/commands/diagnose.rs
@@ -400,10 +400,7 @@ pub async fn execute(
cli: &super::Cli,
console: &Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
let mut exit_code: i32 = 0;
diff --git a/crates/mozart/src/commands/dump_autoload.rs b/crates/mozart/src/commands/dump_autoload.rs
index ec25b54..15253e8 100644
--- a/crates/mozart/src/commands/dump_autoload.rs
+++ b/crates/mozart/src/commands/dump_autoload.rs
@@ -1,5 +1,4 @@
use clap::Args;
-use std::path::PathBuf;
#[derive(Args)]
pub struct DumpAutoloadArgs {
@@ -58,10 +57,7 @@ pub async fn execute(
anyhow::bail!("You can not use both --no-dev and --dev as they conflict with each other.");
}
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
let vendor_dir = working_dir.join("vendor");
let dev_mode = !args.no_dev;
diff --git a/crates/mozart/src/commands/exec.rs b/crates/mozart/src/commands/exec.rs
index 5f1f0bc..9555601 100644
--- a/crates/mozart/src/commands/exec.rs
+++ b/crates/mozart/src/commands/exec.rs
@@ -25,10 +25,7 @@ pub async fn execute(
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
use mozart_core::console::Verbosity;
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// ExecCommand uses requireComposer in Composer; composer.json must exist.
let composer = Composer::require(&working_dir)?;
diff --git a/crates/mozart/src/commands/fund.rs b/crates/mozart/src/commands/fund.rs
index 1cd78b7..bebf8c2 100644
--- a/crates/mozart/src/commands/fund.rs
+++ b/crates/mozart/src/commands/fund.rs
@@ -3,7 +3,7 @@ use mozart_core::console;
use mozart_core::console_format;
use serde::Serialize;
use std::collections::BTreeMap;
-use std::path::{Path, PathBuf};
+use std::path::Path;
#[derive(Args)]
pub struct FundArgs {
@@ -31,10 +31,7 @@ pub async fn execute(
cli: &super::Cli,
console: &console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// Validate format
let format = args.format.as_deref().unwrap_or("text");
diff --git a/crates/mozart/src/commands/init.rs b/crates/mozart/src/commands/init.rs
index 209be4b..3378755 100644
--- a/crates/mozart/src/commands/init.rs
+++ b/crates/mozart/src/commands/init.rs
@@ -10,7 +10,7 @@ use mozart_core::validation;
use mozart_registry::{packagist, version};
use std::collections::BTreeMap;
use std::io::{BufRead, Write};
-use std::path::{Path, PathBuf};
+use std::path::Path;
use std::process::Command;
#[derive(Args)]
@@ -68,10 +68,7 @@ pub async fn execute(
let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache);
let repo_cache = mozart_registry::cache::Cache::repo(&cache_config);
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir().context("Failed to get current directory")?,
- };
+ let working_dir = cli.working_dir()?;
let composer_file = working_dir.join("composer.json");
if composer_file.exists() {
diff --git a/crates/mozart/src/commands/install.rs b/crates/mozart/src/commands/install.rs
index a759e2b..91d73e0 100644
--- a/crates/mozart/src/commands/install.rs
+++ b/crates/mozart/src/commands/install.rs
@@ -10,7 +10,7 @@ use mozart_registry::installer_executor::{
};
use mozart_registry::lockfile;
use std::collections::BTreeMap;
-use std::path::{Path, PathBuf};
+use std::path::Path;
#[derive(Args)]
pub struct InstallArgs {
@@ -159,14 +159,6 @@ pub struct InstallOp<'a> {
pub action: Action,
}
-/// Resolve the working directory from the CLI option, falling back to cwd.
-pub fn resolve_working_dir(cli: &super::Cli) -> PathBuf {
- match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir().expect("Failed to determine current directory"),
- }
-}
-
/// Compute install operations by comparing locked packages against installed packages.
///
/// Returns a tuple of (ops, removals) where:
@@ -1333,7 +1325,7 @@ pub async fn execute(
mozart_registry::cache::Cache::repo(&cache_config),
));
let mut executor = FilesystemExecutor::new(mozart_registry::cache::Cache::files(&cache_config));
- let working_dir = resolve_working_dir(cli);
+ let working_dir = cli.working_dir()?;
run(
&working_dir,
None,
diff --git a/crates/mozart/src/commands/licenses.rs b/crates/mozart/src/commands/licenses.rs
index 5ce2b35..595cf43 100644
--- a/crates/mozart/src/commands/licenses.rs
+++ b/crates/mozart/src/commands/licenses.rs
@@ -2,7 +2,7 @@ use clap::Args;
use indexmap::IndexSet;
use mozart_core::console::{Console, Verbosity};
use serde::Serialize;
-use std::path::{Path, PathBuf};
+use std::path::Path;
#[derive(Args)]
pub struct LicensesArgs {
@@ -34,10 +34,7 @@ pub async fn execute(
cli: &super::Cli,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// Validate format
let format = args.format.as_deref().unwrap_or("text");
diff --git a/crates/mozart/src/commands/outdated.rs b/crates/mozart/src/commands/outdated.rs
index 5a4f854..61a1e8b 100644
--- a/crates/mozart/src/commands/outdated.rs
+++ b/crates/mozart/src/commands/outdated.rs
@@ -2,7 +2,7 @@ use clap::Args;
use indexmap::IndexSet;
use mozart_core::matches_wildcard;
use std::cmp::Ordering;
-use std::path::{Path, PathBuf};
+use std::path::Path;
#[derive(Args)]
pub struct OutdatedArgs {
@@ -111,10 +111,7 @@ pub async fn execute(
anyhow::bail!("Only one of --major-only, --minor-only or --patch-only can be used at once");
}
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// Load packages (installed or locked)
let packages = if args.locked {
diff --git a/crates/mozart/src/commands/reinstall.rs b/crates/mozart/src/commands/reinstall.rs
index 2df55c5..e959486 100644
--- a/crates/mozart/src/commands/reinstall.rs
+++ b/crates/mozart/src/commands/reinstall.rs
@@ -1,7 +1,6 @@
use clap::Args;
use mozart_core::console_format;
use mozart_core::package;
-use std::path::PathBuf;
#[derive(Args)]
pub struct ReinstallArgs {
@@ -72,11 +71,7 @@ pub async fn execute(
cli: &super::Cli,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
- // Step 1: Resolve working directory
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
let vendor_dir = working_dir.join("vendor");
diff --git a/crates/mozart/src/commands/remove.rs b/crates/mozart/src/commands/remove.rs
index 6498e01..a25d557 100644
--- a/crates/mozart/src/commands/remove.rs
+++ b/crates/mozart/src/commands/remove.rs
@@ -118,8 +118,7 @@ pub async fn execute(
console.info(&console_format!("<warning>The -W / --update-with-all-dependencies flag is deprecated. Use --with-all-dependencies instead.</warning>"));
}
- // Step 3: Resolve working directory and read composer.json
- let working_dir = super::install::resolve_working_dir(cli);
+ let working_dir = cli.working_dir()?;
let composer_path = working_dir.join("composer.json");
if !composer_path.exists() {
diff --git a/crates/mozart/src/commands/repository.rs b/crates/mozart/src/commands/repository.rs
index e8ca920..7b5b7a3 100644
--- a/crates/mozart/src/commands/repository.rs
+++ b/crates/mozart/src/commands/repository.rs
@@ -4,8 +4,7 @@ use std::path::PathBuf;
use super::config_helpers::{
add_repository, composer_home, ensure_repositories_array, find_repo_by_name, insert_repository,
- normalize_repositories, read_json_file, remove_repository, render_value, working_dir,
- write_json_file,
+ normalize_repositories, read_json_file, remove_repository, render_value, write_json_file,
};
#[derive(Args)]
@@ -53,7 +52,7 @@ fn resolve_file_path(args: &RepositoryArgs, cli: &super::Cli) -> anyhow::Result<
if let Some(ref file) = args.file {
return Ok(PathBuf::from(file));
}
- Ok(working_dir(cli)?.join("composer.json"))
+ Ok(cli.working_dir()?.join("composer.json"))
}
pub async fn execute(
diff --git a/crates/mozart/src/commands/require.rs b/crates/mozart/src/commands/require.rs
index 02e5d8e..08ee6ea 100644
--- a/crates/mozart/src/commands/require.rs
+++ b/crates/mozart/src/commands/require.rs
@@ -348,7 +348,7 @@ pub async fn execute(
}
// Interactive search — we need composer.json first to know what's already required.
// We'll perform a quick check that composer.json exists, then run the search.
- let working_dir = super::install::resolve_working_dir(cli);
+ let working_dir = cli.working_dir()?;
let composer_path = working_dir.join("composer.json");
if !composer_path.exists() {
anyhow::bail!(
@@ -411,8 +411,7 @@ pub async fn execute(
console.info(&console_format!("<warning>The -W / --update-with-all-dependencies flag is deprecated. Use --with-all-dependencies instead.</warning>"));
}
- // Resolve working directory
- let working_dir = super::install::resolve_working_dir(cli);
+ let working_dir = cli.working_dir()?;
let composer_path = working_dir.join("composer.json");
if !composer_path.exists() {
diff --git a/crates/mozart/src/commands/run_script.rs b/crates/mozart/src/commands/run_script.rs
index e57d1c2..ab07b84 100644
--- a/crates/mozart/src/commands/run_script.rs
+++ b/crates/mozart/src/commands/run_script.rs
@@ -79,10 +79,7 @@ pub async fn execute(
cli: &super::Cli,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// RunScriptCommand uses requireComposer in Composer; composer.json must exist.
let composer = mozart_core::composer::Composer::require(&working_dir)?;
diff --git a/crates/mozart/src/commands/show.rs b/crates/mozart/src/commands/show.rs
index cf15bb2..6c72540 100644
--- a/crates/mozart/src/commands/show.rs
+++ b/crates/mozart/src/commands/show.rs
@@ -3,7 +3,7 @@ use indexmap::{IndexMap, IndexSet};
use mozart_core::console::Verbosity;
use mozart_core::console_format;
use mozart_core::matches_wildcard;
-use std::path::{Path, PathBuf};
+use std::path::Path;
#[derive(Args)]
pub struct ShowArgs {
@@ -166,10 +166,7 @@ pub async fn execute(
);
}
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// --platform: show detected platform packages
if args.platform {
diff --git a/crates/mozart/src/commands/status.rs b/crates/mozart/src/commands/status.rs
index 29b1e1b..b8585dc 100644
--- a/crates/mozart/src/commands/status.rs
+++ b/crates/mozart/src/commands/status.rs
@@ -51,10 +51,7 @@ pub async fn execute(
cli: &super::Cli,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
let vendor_dir = working_dir.join("vendor");
let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?;
diff --git a/crates/mozart/src/commands/suggests.rs b/crates/mozart/src/commands/suggests.rs
index 6d1765e..61185b2 100644
--- a/crates/mozart/src/commands/suggests.rs
+++ b/crates/mozart/src/commands/suggests.rs
@@ -5,7 +5,7 @@ use mozart_core::console;
use mozart_core::console::Verbosity;
use mozart_core::console_format;
use std::collections::BTreeMap;
-use std::path::{Path, PathBuf};
+use std::path::Path;
#[derive(Args)]
pub struct SuggestsArgs {
@@ -48,10 +48,7 @@ pub async fn execute(
cli: &super::Cli,
console: &console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
let lock_path = working_dir.join("composer.lock");
let has_lock = lock_path.exists();
diff --git a/crates/mozart/src/commands/update.rs b/crates/mozart/src/commands/update.rs
index 2a0aa88..aa19675 100644
--- a/crates/mozart/src/commands/update.rs
+++ b/crates/mozart/src/commands/update.rs
@@ -996,7 +996,7 @@ pub async fn execute(
let mut executor = mozart_registry::installer_executor::FilesystemExecutor::new(
mozart_registry::cache::Cache::files(&cache_config),
);
- let working_dir = super::install::resolve_working_dir(cli);
+ let working_dir = cli.working_dir()?;
run(
&working_dir,
None,
diff --git a/crates/mozart/src/commands/validate.rs b/crates/mozart/src/commands/validate.rs
index a0c6907..d7bd9fb 100644
--- a/crates/mozart/src/commands/validate.rs
+++ b/crates/mozart/src/commands/validate.rs
@@ -93,10 +93,7 @@ pub async fn execute(
cli: &super::Cli,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
- let working_dir = match &cli.working_dir {
- Some(dir) => PathBuf::from(dir),
- None => std::env::current_dir()?,
- };
+ let working_dir = cli.working_dir()?;
// Determine which file to validate
let file = match &args.file {