Deprecated subcommands

They should still work, but shouldn't show up in help or usage output
This commit is contained in:
Eric Paris
2015-04-07 17:38:22 -04:00
parent 69e5f196b5
commit c3e48f996d
6 changed files with 48 additions and 5 deletions

View File

@ -51,6 +51,15 @@ var cmdEchoSub = &Command{
},
}
var cmdDeprecated = &Command{
Use: "deprecated [can't do anything here]",
Short: "A command which is deprecated",
Long: `an absolutely utterly useless command for testing deprecation!.`,
Deprecated: "Please use echo instead",
Run: func(cmd *Command, args []string) {
},
}
var cmdTimes = &Command{
Use: "times [# times] [string to echo]",
Short: "Echo anything to the screen more times",
@ -205,7 +214,7 @@ func fullTester(c *Command, input string) resulter {
// Testing flag with invalid input
c.SetOutput(buf)
cmdEcho.AddCommand(cmdTimes)
c.AddCommand(cmdPrint, cmdEcho, cmdSubNoRun)
c.AddCommand(cmdPrint, cmdEcho, cmdSubNoRun, cmdDeprecated)
c.SetArgs(strings.Split(input, " "))
err := c.Execute()
@ -812,3 +821,9 @@ func TestReplaceCommandWithRemove(t *testing.T) {
t.Errorf("Replacing command should have been called but didn't\n")
}
}
func TestDeprecatedSub(t *testing.T) {
c := fullSetupTest("deprecated")
checkResultContains(t, c, cmdDeprecated.Deprecated)
}