This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 19e268e1e2cd16f788dc2d2141548c284e59785c
Author: Damian Meden <[email protected]>
AuthorDate: Fri Feb 27 09:31:34 2026 +0100

    tools -  traffic_ctl, traffic_layout: use ArgParse groups to handle 
mutually exclusive options. (#12623)
    
    * tools -  traffic_ctl, traffic_layout: use ArgParse groups to handle
    mutually exclusive options.
    
    traffic_ctl:
    
    Usage: traffic_ctl [OPTIONS] CMD [ARGS ...]
    
    Commands ---------------------- Description -----------------------
    drain                           Drain the requests
    
    Options ======================= Default ===== Description =============
    
    Group (drain_mode)
      -N, --no-new-connection                     Wait for new connections down 
to threshold before starting draining
      -U, --undo                                  Recover server from the drain 
mode
    
    traffic_layout:
    
    Usage: traffic_layout CMD [OPTIONS]
    
    Commands ---------------------- Description -----------------------
    info                            Show the layout as default
    
    Options ======================= Default ===== Description =============
    -j, --json                                    Produce output in JSON format 
(when supported)
    
    Group (display_mode)
      --features                                  Show the compiled features
      --versions                                  Show various library and 
other versioning information
    
    (cherry picked from commit bb4b904808cc73d9b9e9ce59847f4f09e4081206)
---
 src/traffic_ctl/traffic_ctl.cc       | 14 +++++++++-----
 src/traffic_layout/traffic_layout.cc | 11 ++++++-----
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/traffic_ctl/traffic_ctl.cc b/src/traffic_ctl/traffic_ctl.cc
index 6529c0f88b..1f6bc41686 100644
--- a/src/traffic_ctl/traffic_ctl.cc
+++ b/src/traffic_ctl/traffic_ctl.cc
@@ -183,11 +183,15 @@ main([[maybe_unused]] int argc, const char **argv)
   // server commands
   server_command.add_command("backtrace", "Show a full stack trace of the 
traffic_server process",
                              [&]() { CtrlUnimplementedCommand("backtrace"); });
-  server_command.add_command("status", "Show the proxy status", 
Command_Execute).add_example_usage("traffic_ctl server status");
-  server_command.add_command("drain", "Drain the requests", Command_Execute)
-    .add_example_usage("traffic_ctl server drain [OPTIONS]")
-    .add_option("--no-new-connection", "-N", "Wait for new connections down to 
threshold before starting draining")
-    .add_option("--undo", "-U", "Recover server from the drain mode");
+  server_command.add_command("status", "Show the proxy status", [&]() { 
command->execute(); })
+    .add_example_usage("traffic_ctl server status");
+  auto &drain_cmd = server_command.add_command("drain", "Drain the requests", 
[&]() { command->execute(); });
+  drain_cmd.add_example_usage("traffic_ctl server drain [OPTIONS]");
+
+  drain_cmd.add_mutex_group("drain_mode", false, "Drain mode options");
+  drain_cmd.add_option_to_group("drain_mode", "--no-new-connection", "-N",
+                                "Wait for new connections down to threshold 
before starting draining");
+  drain_cmd.add_option_to_group("drain_mode", "--undo", "-U", "Recover server 
from the drain mode");
 
   auto &debug_command =
     server_command.add_command("debug", "Enable/Disable ATS for diagnostic 
messages at runtime").require_commands();
diff --git a/src/traffic_layout/traffic_layout.cc 
b/src/traffic_layout/traffic_layout.cc
index fa28fb5ef2..dcd1465dd4 100644
--- a/src/traffic_layout/traffic_layout.cc
+++ b/src/traffic_layout/traffic_layout.cc
@@ -45,11 +45,12 @@ main([[maybe_unused]] int argc, const char **argv)
     .add_option("--version", "-V", "Print version string");
 
   // info command
-  engine.parser.add_command("info", "Show the layout as default", [&]() { 
engine.info(); })
-    .add_option("--features", "", "Show the compiled features")
-    .add_option("--versions", "", "Show various library and other versioning 
information")
-    .add_option("--json", "-j", "Produce output in JSON format (when 
supported)")
-    .set_default();
+  auto &info_cmd = engine.parser.add_command("info", "Show the layout as 
default", [&]() { engine.info(); });
+  info_cmd.add_mutex_group("display_mode", false, "Display mode options");
+  info_cmd.add_option_to_group("display_mode", "--features", "", "Show the 
compiled features");
+  info_cmd.add_option_to_group("display_mode", "--versions", "", "Show various 
library and other versioning information");
+
+  info_cmd.add_option("--json", "-j", "Produce output in JSON format (when 
supported)").set_default();
   // init command
   engine.parser.add_command("init", "Initialize(create) the runroot sandbox", 
[&]() { engine.create_runroot(); })
     .add_option("--absolute", "-a", "Produce absolute path in the 
runroot.yaml")

Reply via email to