add check to NewCmdExec before printing suggestion

checks that the "describe" command and a parent command path exist
before printing suggestion to use the describe command to list
containers in a pod.
This commit is contained in:
juanvallejo
2016-09-28 12:41:42 -04:00
parent 48370b2802
commit 0988f967f0
4 changed files with 35 additions and 14 deletions

View File

@@ -174,7 +174,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, errOut io.Writer, cmd *cobra.Comm
fullCmdName := cmd.Parent().CommandPath()
usageString := "Required resource not specified."
if len(fullCmdName) > 0 && cmdutil.IsCommandExists(cmd, "explain") {
if len(fullCmdName) > 0 && cmdutil.IsSiblingCommandExists(cmd, "explain") {
usageString = fmt.Sprintf("%s\nUse \"%s explain <resource>\" for a detailed description of that resource (e.g. %[2]s explain pods).", usageString, fullCmdName)
}