suggest use of kube explain <resource> in kube get output

This patch improves usability flow, making it easier for a user to
discover the command `kube explain <resource>` through `kube get`
output.
This commit is contained in:
juanvallejo
2016-09-21 16:14:23 -04:00
parent c0826a2e7e
commit 48370b2802
2 changed files with 9 additions and 2 deletions

View File

@@ -171,7 +171,14 @@ func RunGet(f *cmdutil.Factory, out io.Writer, errOut io.Writer, cmd *cobra.Comm
if len(args) == 0 && cmdutil.IsFilenameEmpty(options.Filenames) {
fmt.Fprint(errOut, "You must specify the type of resource to get. ", valid_resources)
return cmdutil.UsageError(cmd, "Required resource not specified.")
fullCmdName := cmd.Parent().CommandPath()
usageString := "Required resource not specified."
if len(fullCmdName) > 0 && cmdutil.IsCommandExists(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)
}
return cmdutil.UsageError(cmd, usageString)
}
// determine if args contains "all"