grex_cli/cli/deprecation.rs
1//! v1.3.0 deprecation diagnostics for the CLI surface.
2//!
3//! v1.3.0 introduces `--pack` as the canonical pack-root flag on the four
4//! verbs that previously took `--workspace` (`sync`, `serve`,
5//! `migrate-lockfile`, `teardown`). The old `--workspace` spelling is
6//! preserved as a clap `alias` so existing scripts keep parsing, but
7//! every invocation that uses the alias surfaces a one-time deprecation
8//! warning so operators can migrate before removal.
9//!
10//! Detection runs against `std::env::args()` rather than the parsed
11//! `clap::ArgMatches` because clap collapses `--pack` and `--workspace`
12//! into the same field; once parsing completes there is no signal left
13//! that distinguishes which spelling the operator typed.
14//!
15//! Removal target: `v2.0.0` (per `.omne/cfg/freeze-v1.3.0.md` Table M1).
16
17/// Emit a `tracing::warn!` line when the current process was invoked with
18/// the deprecated `--workspace` spelling on a verb that now prefers
19/// `--pack`. Each verb handler calls this at the top of its `run`/
20/// `execute` entry point so the diagnostic fires regardless of which
21/// dispatch path the operator took.
22///
23/// The check accepts both bare-flag form (`--workspace /path`) and
24/// `=`-joined form (`--workspace=/path`) so it does not regress on the
25/// less common but valid clap syntax. Unrelated args that happen to
26/// embed the substring (e.g. a positional `--workspace-something` token)
27/// do NOT trigger the warning because the match is anchored to the full
28/// flag spelling.
29pub fn warn_workspace_alias_used() {
30 if std::env::args().any(|a| a == "--workspace" || a.starts_with("--workspace=")) {
31 tracing::warn!(
32 target: "grex::cli::deprecation",
33 "--workspace is deprecated since v1.3.0; use --pack. Removal scheduled for v2.0.0."
34 );
35 }
36}