@@ -43,6 +43,11 @@ type Command struct {
4343	// Hidden determines whether the command should be hidden from help. 
4444	Hidden  bool 
4545
46+ 	// Deprecated indicates whether this command is deprecated. 
47+ 	// If empty, the command is not deprecated. 
48+ 	// If set, the value is used as the deprecation message. 
49+ 	Deprecated  string  `json:"deprecated,omitempty"` 
50+ 
4651	// RawArgs determines whether the command should receive unparsed arguments. 
4752	// No flags are parsed when set, and the command is responsible for parsing 
4853	// its own flags. 
@@ -316,6 +321,13 @@ func (inv *Invocation) CurWords() (prev string, cur string) {
316321// allArgs is wired through the stack so that global flags can be accepted 
317322// anywhere in the command invocation. 
318323func  (inv  * Invocation ) run (state  * runState ) error  {
324+ 	if  inv .Command .Deprecated  !=  ""  {
325+ 		fmt .Fprintf (inv .Stderr , "%s %q is deprecated!. %s\n " ,
326+ 			prettyHeader ("warning" ),
327+ 			inv .Command .FullName (),
328+ 			inv .Command .Deprecated ,
329+ 		)
330+ 	}
319331	err  :=  inv .Command .Options .ParseEnv (inv .Environ )
320332	if  err  !=  nil  {
321333		return  xerrors .Errorf ("parsing env: %w" , err )
0 commit comments