Skip to content

Commit

Permalink
Set SilenceUsage at Root cmd level
Browse files Browse the repository at this point in the history
  • Loading branch information
suizman committed Apr 11, 2019
1 parent 941a913 commit 96994f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ three agents into the distribution:
var agentCtx context.Context = configAgent()

func init() {
agentCmd.SilenceUsage = true
agentCmd.MarkFlagRequired("bind-addr")
agentCmd.MarkFlagRequired("metrics-addr")
agentCmd.MarkFlagRequired("node-name")
Expand All @@ -58,4 +59,3 @@ func configAgent() context.Context {

return context.WithValue(Ctx, k("agent.config"), conf)
}

5 changes: 1 addition & 4 deletions cmd/client_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ func init() {
}

func runClientAdd(cmd *cobra.Command, args []string) error {
// SilenceUsage is set to true -> https://github.com/spf13/cobra/issues/340

if clientAddEvent == "" {
return fmt.Errorf("Event must not be empty!")
}

cmd.SilenceUsage = true

config := clientCtx.Value(k("client.config")).(*client.Config)
log.SetLogger("client", config.Log)

Expand All @@ -69,4 +67,3 @@ func runClientAdd(cmd *cobra.Command, args []string) error {

return nil
}

2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var Root *cobra.Command = &cobra.Command{
Use: "qed",
Short: "QED system",
Long: "QED implements an authenticated data structure as an append-only log. This command exposes the QED components. Please refer to QED manual to learn about QED architecture and its components",
// SilenceUsage is set to true -> https://github.com/spf13/cobra/issues/340
SilenceUsage: true,
}

var Ctx context.Context = context.WithValue(context.Background(), k("version"), "alpha")

0 comments on commit 96994f1

Please sign in to comment.