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

chore: add removal warning to deprecated flags #7890

Merged
merged 2 commits into from
Apr 15, 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
36 changes: 35 additions & 1 deletion crates/turborepo-lib/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::{
use clap_complete::{generate, Shell};
pub use error::Error;
use serde::{Deserialize, Serialize};
use tracing::{debug, error};
use tracing::{debug, error, warn};
use turbopath::AbsoluteSystemPathBuf;
use turborepo_api_client::AnonAPIClient;
use turborepo_repository::inference::{RepoMode, RepoState};
Expand Down Expand Up @@ -1049,6 +1049,7 @@ pub async fn run(
root_telemetry.track_cpus(num_cpus::get());
// track args
cli_args.track(&root_telemetry);
warn_all_deprecated_flags(&cli_args);

let cli_result = match cli_args.command.as_ref().unwrap() {
Command::Bin { .. } => {
Expand Down Expand Up @@ -1259,6 +1260,39 @@ pub async fn run(
cli_result
}

fn warn_all_deprecated_flags(args: &Args) {
if args.trace.is_some() {
warn_flag_removal("--trace");
}

if args.heap.is_some() {
warn_flag_removal("--heap");
}

if args.cpu_profile.is_some() {
warn_flag_removal("--cpuprofile");
}

if let Some(Command::Run(run_args)) = args.command.as_ref() {
if run_args.since.is_some() {
warn_flag_removal("--since");
}
if !run_args.scope.is_empty() {
warn_flag_removal("--scope");
}
if run_args.include_dependencies {
warn_flag_removal("--include-dependencies");
}
if run_args.no_deps {
warn_flag_removal("--no-deps");
}
}
}

fn warn_flag_removal(flag: &str) {
warn!("{flag} is deprecated and will be removed in 2.0");
}

#[cfg(test)]
mod test {
use std::assert_matches::assert_matches;
Expand Down
Loading