3636//! long-running commands are classified correctly, and high-impact mutations
3737//! expose safety, dry-run, wait/watch, stdin, and schema metadata.
3838
39- use crate :: Cli ;
4039use crate :: args:: CommandsArgs ;
4140use crate :: commands:: output:: emit_read;
4241use crate :: commands:: schemas:: {
@@ -46,6 +45,7 @@ use crate::commands::schemas::{
4645} ;
4746use crate :: error:: CliError ;
4847use crate :: style:: HumanStyle ;
48+ use crate :: { BIN_NAME , Cli } ;
4949use clap:: builder:: ValueRange ;
5050use clap:: { Arg , ArgAction , Command as ClapCommand , CommandFactory } ;
5151use serde:: Serialize ;
@@ -54,7 +54,6 @@ use std::io::Write;
5454use std:: time:: SystemTime ;
5555
5656const SCHEMA_VERSION : & str = "dfctl-command-catalog/v1" ;
57- const BIN_NAME : & str = "dfctl" ;
5857
5958/// Runs `dfctl commands` and emits either a compact human table or the full
6059/// machine-readable catalog, depending on the selected output mode.
@@ -345,7 +344,7 @@ fn supports_dry_run(arguments: &[ArgumentEntry]) -> bool {
345344
346345/// Builds a stable, dot-separated command identifier.
347346fn command_id ( path : & [ String ] ) -> String {
348- format ! ( "dfctl .{}" , path. join( "." ) . replace( '-' , "_" ) )
347+ format ! ( "{BIN_NAME} .{}" , path. join( "." ) . replace( '-' , "_" ) )
349348}
350349
351350/// Builds the shortest command-line prefix for a command path.
@@ -435,91 +434,130 @@ fn curated_examples(path: &[String]) -> Vec<String> {
435434 . collect :: < Vec < _ > > ( )
436435 . as_slice ( )
437436 {
438- [ "commands" ] => vec ! [ "dfctl commands --output json". to_string ( ) ] ,
437+ [ "commands" ] => vec ! [ command_example ( " commands --output json") ] ,
439438 [ "schemas" ] => vec ! [
440- "dfctl schemas --output json". to_string ( ) ,
441- "dfctl schemas dfctl.error.v1 --output json". to_string ( ) ,
439+ command_example ( " schemas --output json") ,
440+ command_example ( " schemas dfctl.error.v1 --output json") ,
442441 ] ,
443- [ "completions" ] => vec ! [ "dfctl completions bash". to_string ( ) ] ,
444- [ "completions" , "install" ] => vec ! [ "dfctl completions install zsh". to_string ( ) ] ,
445- [ "config" , "view" ] => vec ! [ "dfctl config view --output json". to_string ( ) ] ,
446- [ "ui" ] => vec ! [ "dfctl ui --start-view pipelines". to_string ( ) ] ,
447- [ "engine" , "status" ] => vec ! [ "dfctl engine status --output json". to_string ( ) ] ,
448- [ "engine" , "livez" ] => vec ! [ "dfctl engine livez". to_string ( ) ] ,
449- [ "engine" , "readyz" ] => vec ! [ "dfctl engine readyz". to_string ( ) ] ,
450- [ "groups" , "status" ] => vec ! [ "dfctl groups status". to_string ( ) ] ,
451- [ "groups" , "describe" ] => vec ! [ "dfctl groups describe". to_string ( ) ] ,
452- [ "groups" , "events" , "get" ] => vec ! [ "dfctl groups events get --tail 20". to_string ( ) ] ,
442+ [ "completions" ] => vec ! [ command_example ( " completions bash") ] ,
443+ [ "completions" , "install" ] => vec ! [ command_example ( " completions install zsh") ] ,
444+ [ "config" , "view" ] => vec ! [ command_example ( " config view --output json") ] ,
445+ [ "ui" ] => vec ! [ command_example ( " ui --start-view pipelines") ] ,
446+ [ "engine" , "status" ] => vec ! [ command_example ( " engine status --output json") ] ,
447+ [ "engine" , "livez" ] => vec ! [ command_example ( " engine livez") ] ,
448+ [ "engine" , "readyz" ] => vec ! [ command_example ( " engine readyz") ] ,
449+ [ "groups" , "status" ] => vec ! [ command_example ( " groups status") ] ,
450+ [ "groups" , "describe" ] => vec ! [ command_example ( " groups describe") ] ,
451+ [ "groups" , "events" , "get" ] => vec ! [ command_example ( " groups events get --tail 20") ] ,
453452 [ "groups" , "events" , "watch" ] => {
454- vec ! [ "dfctl groups events watch --kind error --tail 20" . to_string( ) ]
453+ vec ! [ command_example(
454+ "groups events watch --kind error --tail 20" ,
455+ ) ]
455456 }
456- [ "groups" , "diagnose" , "shutdown" ] => vec ! [ "dfctl groups diagnose shutdown". to_string ( ) ] ,
457- [ "groups" , "bundle" ] => vec ! [ "dfctl groups bundle --file bundle.json". to_string ( ) ] ,
458- [ "groups" , "shutdown" ] => vec ! [ "dfctl groups shutdown --watch". to_string ( ) ] ,
459- [ "pipelines" , "get" ] => vec ! [ "dfctl pipelines get tenant-a ingest". to_string ( ) ] ,
457+ [ "groups" , "diagnose" , "shutdown" ] => vec ! [ command_example ( " groups diagnose shutdown") ] ,
458+ [ "groups" , "bundle" ] => vec ! [ command_example ( " groups bundle --file bundle.json") ] ,
459+ [ "groups" , "shutdown" ] => vec ! [ command_example ( " groups shutdown --watch") ] ,
460+ [ "pipelines" , "get" ] => vec ! [ command_example ( " pipelines get tenant-a ingest") ] ,
460461 [ "pipelines" , "describe" ] => {
461- vec ! [ "dfctl pipelines describe tenant-a ingest". to_string ( ) ]
462+ vec ! [ command_example ( " pipelines describe tenant-a ingest") ]
462463 }
463464 [ "pipelines" , "status" ] => {
464- vec ! [ "dfctl pipelines status tenant-a ingest --output json" . to_string( ) ]
465+ vec ! [ command_example(
466+ "pipelines status tenant-a ingest --output json" ,
467+ ) ]
465468 }
466- [ "pipelines" , "livez" ] => vec ! [ "dfctl pipelines livez tenant-a ingest". to_string ( ) ] ,
467- [ "pipelines" , "readyz" ] => vec ! [ "dfctl pipelines readyz tenant-a ingest". to_string ( ) ] ,
469+ [ "pipelines" , "livez" ] => vec ! [ command_example ( " pipelines livez tenant-a ingest") ] ,
470+ [ "pipelines" , "readyz" ] => vec ! [ command_example ( " pipelines readyz tenant-a ingest") ] ,
468471 [ "pipelines" , "events" , "get" ] => {
469- vec ! [ "dfctl pipelines events get tenant-a ingest --tail 20" . to_string( ) ]
472+ vec ! [ command_example(
473+ "pipelines events get tenant-a ingest --tail 20" ,
474+ ) ]
470475 }
471476 [ "pipelines" , "events" , "watch" ] => {
472- vec ! [ "dfctl pipelines events watch tenant-a ingest --kind error --tail 20" . to_string( ) ]
477+ vec ! [ command_example(
478+ "pipelines events watch tenant-a ingest --kind error --tail 20" ,
479+ ) ]
473480 }
474481 [ "pipelines" , "diagnose" , "rollout" ] => {
475- vec ! [ "dfctl pipelines diagnose rollout tenant-a ingest" . to_string( ) ]
482+ vec ! [ command_example(
483+ "pipelines diagnose rollout tenant-a ingest" ,
484+ ) ]
476485 }
477486 [ "pipelines" , "diagnose" , "shutdown" ] => {
478- vec ! [ "dfctl pipelines diagnose shutdown tenant-a ingest" . to_string( ) ]
487+ vec ! [ command_example(
488+ "pipelines diagnose shutdown tenant-a ingest" ,
489+ ) ]
479490 }
480491 [ "pipelines" , "bundle" ] => {
481- vec ! [ "dfctl pipelines bundle tenant-a ingest --file bundle.json" . to_string( ) ]
492+ vec ! [ command_example(
493+ "pipelines bundle tenant-a ingest --file bundle.json" ,
494+ ) ]
482495 }
483- [ "pipelines" , "reconfigure" ] => vec ! [
484- "dfctl pipelines reconfigure tenant-a ingest --file pipeline.yaml --wait" . to_string ( ) ,
485- ] ,
496+ [ "pipelines" , "reconfigure" ] => vec ! [ command_example (
497+ "pipelines reconfigure tenant-a ingest --file pipeline.yaml --wait" ,
498+ ) ] ,
486499 [ "pipelines" , "shutdown" ] => {
487- vec ! [ "dfctl pipelines shutdown tenant-a ingest --watch" . to_string( ) ]
500+ vec ! [ command_example(
501+ "pipelines shutdown tenant-a ingest --watch" ,
502+ ) ]
488503 }
489504 [ "pipelines" , "rollouts" , "get" ] => {
490- vec ! [ "dfctl pipelines rollouts get tenant-a ingest rollout-1" . to_string( ) ]
505+ vec ! [ command_example(
506+ "pipelines rollouts get tenant-a ingest rollout-1" ,
507+ ) ]
491508 }
492509 [ "pipelines" , "rollouts" , "watch" ] => {
493- vec ! [ "dfctl pipelines rollouts watch tenant-a ingest rollout-1" . to_string( ) ]
510+ vec ! [ command_example(
511+ "pipelines rollouts watch tenant-a ingest rollout-1" ,
512+ ) ]
494513 }
495514 [ "pipelines" , "rollout-status" ] => {
496- vec ! [ "dfctl pipelines rollout-status tenant-a ingest rollout-1" . to_string( ) ]
515+ vec ! [ command_example(
516+ "pipelines rollout-status tenant-a ingest rollout-1" ,
517+ ) ]
497518 }
498519 [ "pipelines" , "shutdowns" , "get" ] => {
499- vec ! [ "dfctl pipelines shutdowns get tenant-a ingest shutdown-1" . to_string( ) ]
520+ vec ! [ command_example(
521+ "pipelines shutdowns get tenant-a ingest shutdown-1" ,
522+ ) ]
500523 }
501524 [ "pipelines" , "shutdowns" , "watch" ] => {
502- vec ! [ "dfctl pipelines shutdowns watch tenant-a ingest shutdown-1" . to_string( ) ]
525+ vec ! [ command_example(
526+ "pipelines shutdowns watch tenant-a ingest shutdown-1" ,
527+ ) ]
503528 }
504529 [ "pipelines" , "shutdown-status" ] => {
505- vec ! [ "dfctl pipelines shutdown-status tenant-a ingest shutdown-1" . to_string( ) ]
530+ vec ! [ command_example(
531+ "pipelines shutdown-status tenant-a ingest shutdown-1" ,
532+ ) ]
506533 }
507534 [ "telemetry" , "logs" , "get" ] => {
508- vec ! [ "dfctl telemetry logs get --limit 50 --output json" . to_string( ) ]
535+ vec ! [ command_example(
536+ "telemetry logs get --limit 50 --output json" ,
537+ ) ]
509538 }
510539 [ "telemetry" , "logs" , "watch" ] => {
511- vec ! [ "dfctl telemetry logs watch --tail 50". to_string ( ) ]
540+ vec ! [ command_example ( " telemetry logs watch --tail 50") ]
512541 }
513542 [ "telemetry" , "metrics" , "get" ] => {
514- vec ! [ "dfctl telemetry metrics get --shape compact --output json" . to_string( ) ]
543+ vec ! [ command_example(
544+ "telemetry metrics get --shape compact --output json" ,
545+ ) ]
515546 }
516547 [ "telemetry" , "metrics" , "watch" ] => {
517- vec ! [ "dfctl telemetry metrics watch --shape compact --output ndjson" . to_string( ) ]
548+ vec ! [ command_example(
549+ "telemetry metrics watch --shape compact --output ndjson" ,
550+ ) ]
518551 }
519552 _ => Vec :: new ( ) ,
520553 }
521554}
522555
556+ /// Builds a curated command example from the shared binary name.
557+ fn command_example ( args : & str ) -> String {
558+ format ! ( "{BIN_NAME} {args}" )
559+ }
560+
523561/// Returns the best display placeholder for an argument value.
524562fn value_placeholder ( argument : & ArgumentEntry ) -> String {
525563 argument
@@ -709,7 +747,7 @@ fn render_human(style: &HumanStyle, catalog: &CommandCatalog) -> String {
709747 . collect :: < Vec < _ > > ( ) ;
710748
711749 let lines = [
712- style. header ( "dfctl command catalog") ,
750+ style. header ( format ! ( "{BIN_NAME} command catalog") ) ,
713751 format ! ( "{}: {}" , style. label( "schema" ) , catalog. schema_version) ,
714752 format ! ( "{}: {}" , style. label( "commands" ) , catalog. commands. len( ) ) ,
715753 String :: new ( ) ,
@@ -722,7 +760,7 @@ fn render_human(style: &HumanStyle, catalog: &CommandCatalog) -> String {
722760 rows,
723761 ) ,
724762 String :: new ( ) ,
725- "Use `dfctl commands --output json` for the machine-readable catalog." . to_string ( ) ,
763+ format ! ( "Use `{BIN_NAME} commands --output json` for the machine-readable catalog." ) ,
726764 ] ;
727765 lines. join ( "\n " )
728766}
@@ -1073,7 +1111,7 @@ mod tests {
10731111 pipeline_get. output_modes,
10741112 vec![ "human" , "json" , "yaml" , "agent-json" ]
10751113 ) ;
1076- assert_eq ! ( pipeline_get. id, "dfctl .pipelines.get") ;
1114+ assert_eq ! ( pipeline_get. id, format! ( "{BIN_NAME} .pipelines.get") ) ;
10771115 assert_eq ! ( pipeline_get. default_output. as_deref( ) , Some ( "human" ) ) ;
10781116 assert_eq ! (
10791117 pipeline_get. agent_default_output. as_deref( ) ,
0 commit comments