mirror of https://github.com/knative/client.git
Add SilenceUsage option to cobra command (#43)
* Add SilenceUsage option to cobra command This patch adds `cmd.SilenceUsage` to command to stop usage output after command validation. Fixes https://github.com/knative/client/issues/38 * Set cmd.SilenceUsage to global cmd
This commit is contained in:
parent
72ec64390b
commit
e8ec699d2c
|
|
@ -65,6 +65,9 @@ func NewKnCommand(params ...KnParams) *cobra.Command {
|
|||
Serving: Manage your services and release new software to them.
|
||||
Build: Create builds and keep track of their results.
|
||||
Eventing: Manage event subscriptions and channels. Connect up event sources.`,
|
||||
|
||||
// Affects children as well
|
||||
SilenceUsage: true,
|
||||
}
|
||||
if p.Output != nil {
|
||||
rootCmd.SetOutput(p.Output)
|
||||
|
|
|
|||
|
|
@ -30,15 +30,14 @@ func NewServiceDescribeCommand(p *KnParams) *cobra.Command {
|
|||
Use: "describe NAME",
|
||||
Short: "Describe available services.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) < 1 {
|
||||
return errors.New("requires the service name.")
|
||||
}
|
||||
client, err := p.ServingFactory()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(args) < 1 {
|
||||
return errors.New("requires the service name.")
|
||||
}
|
||||
|
||||
namespace := cmd.Flag("namespace").Value.String()
|
||||
describeService, err := client.Services(namespace).Get(args[0], v1.GetOptions{})
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue