From f019a35581839b5e1e842dc1e83a558c30336252 Mon Sep 17 00:00:00 2001 From: Adam Spofford Date: Thu, 16 Apr 2026 14:36:22 -0700 Subject: [PATCH 1/3] Add deprecation notice --- src/dfx/src/lib/warning.rs | 2 ++ src/dfx/src/main.rs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/dfx/src/lib/warning.rs b/src/dfx/src/lib/warning.rs index fa7b4e3d03..6d5841808d 100644 --- a/src/dfx/src/lib/warning.rs +++ b/src/dfx/src/lib/warning.rs @@ -1,10 +1,12 @@ pub enum DfxWarning { MainnetPlainTextIdentity, + Deprecation, } pub fn is_warning_disabled(warning: DfxWarning) -> bool { let warning = match warning { DfxWarning::MainnetPlainTextIdentity => "mainnet_plaintext_identity", + DfxWarning::Deprecation => "deprecation", }; // By default, warnings are all enabled. let env_warnings = std::env::var("DFX_WARNING").unwrap_or_else(|_| "".to_string()); diff --git a/src/dfx/src/main.rs b/src/dfx/src/main.rs index 69bd20bbf3..3034bad8fa 100644 --- a/src/dfx/src/main.rs +++ b/src/dfx/src/main.rs @@ -6,6 +6,7 @@ use crate::lib::error::DfxResult; use crate::lib::logger::{LoggingMode, create_root_logger}; use crate::lib::project::templates::builtin_templates; use crate::lib::telemetry::Telemetry; +use crate::lib::warning::{DfxWarning, is_warning_disabled}; use anyhow::Error; use clap::{ArgAction, CommandFactory, Parser}; use dfx_core::config::model::dfinity::ToolConfig; @@ -193,6 +194,16 @@ fn inner_main(log_level: &mut Option) -> DfxResult { env.get_logger(), "Trace mode enabled. Lots of logs coming up." ); + + if !matches!(cli_opts.command, commands::DfxCommand::Extension(_)) + && !is_warning_disabled(DfxWarning::Deprecation) + { + slog::warn!( + env.get_logger(), + "dfx is deprecated, use icp-cli https://cli.internetcomputer.org. LLM skills can be found at https://skills.internetcomputer.org/llms.txt" + ); + } + commands::exec(&env, cli_opts.command) } From 79b0da26499da520351e82f564e68dd02aa8e500 Mon Sep 17 00:00:00 2001 From: Adam Spofford Date: Thu, 16 Apr 2026 14:56:29 -0700 Subject: [PATCH 2/3] Add notice to help commands --- src/dfx/src/main.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/dfx/src/main.rs b/src/dfx/src/main.rs index 3034bad8fa..9ab1ebbc9b 100644 --- a/src/dfx/src/main.rs +++ b/src/dfx/src/main.rs @@ -8,7 +8,7 @@ use crate::lib::project::templates::builtin_templates; use crate::lib::telemetry::Telemetry; use crate::lib::warning::{DfxWarning, is_warning_disabled}; use anyhow::Error; -use clap::{ArgAction, CommandFactory, Parser}; +use clap::{ArgAction, CommandFactory, FromArgMatches, Parser}; use dfx_core::config::model::dfinity::ToolConfig; use dfx_core::config::project_templates; use dfx_core::extension::installed::InstalledExtensionManifests; @@ -131,6 +131,17 @@ fn print_error_and_diagnosis(log_level: Option, err: Error, error_diagnosis } } +const DEPRECATION_NOTICE: &str = "WARNING: dfx is deprecated, use icp-cli https://cli.internetcomputer.org. LLM skills can be found at https://skills.internetcomputer.org/llms.txt"; + +fn add_deprecation_notices(cmd: &mut clap::Command) { + *cmd = cmd.clone().before_help(DEPRECATION_NOTICE); + for subcmd in cmd.get_subcommands_mut() { + if subcmd.get_name() != "extension" { + add_deprecation_notices(subcmd); + } + } +} + fn get_args_altered_for_extension_run( installed: &InstalledExtensionManifests, ) -> DfxResult> { @@ -169,7 +180,14 @@ fn inner_main(log_level: &mut Option) -> DfxResult { Telemetry::set_platform(); Telemetry::set_week(); - let cli_opts = CliOpts::parse_from(args); + let cli_opts = { + let mut cmd = CliOpts::command(); + if !is_warning_disabled(DfxWarning::Deprecation) { + add_deprecation_notices(&mut cmd); + } + let matches = cmd.get_matches_from(&args); + CliOpts::from_arg_matches(&matches).unwrap_or_else(|e| e.exit()) + }; if matches!( cli_opts.command, From 9f0c49a606a97d629aa9c339bc40af40a638c741 Mon Sep 17 00:00:00 2001 From: Adam Spofford Date: Fri, 17 Apr 2026 08:52:11 -0700 Subject: [PATCH 3/3] use eprintln --- src/dfx/src/main.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/dfx/src/main.rs b/src/dfx/src/main.rs index 9ab1ebbc9b..c7e8ab3652 100644 --- a/src/dfx/src/main.rs +++ b/src/dfx/src/main.rs @@ -216,10 +216,7 @@ fn inner_main(log_level: &mut Option) -> DfxResult { if !matches!(cli_opts.command, commands::DfxCommand::Extension(_)) && !is_warning_disabled(DfxWarning::Deprecation) { - slog::warn!( - env.get_logger(), - "dfx is deprecated, use icp-cli https://cli.internetcomputer.org. LLM skills can be found at https://skills.internetcomputer.org/llms.txt" - ); + eprintln!("{}", DEPRECATION_NOTICE); } commands::exec(&env, cli_opts.command)