diff options
author | Amine <hilalyamine@gmail.com> | 2019-09-06 11:01:09 +0200 |
---|---|---|
committer | Amine <hilalyamine@gmail.com> | 2019-09-06 11:01:09 +0200 |
commit | e5b33ca39c89c6e41bc6c29b8cf87dbae3287450 (patch) | |
tree | 5d6af196a998c5186b08214e1f128b12ab6f1eb6 /commands/root.go | |
parent | 3ad2eeb5d07c14a039e0f0028b84033ff9b2c7db (diff) | |
download | git-bug-e5b33ca39c89c6e41bc6c29b8cf87dbae3287450.tar.gz |
commands: silence usage when cobra commands return an error
Diffstat (limited to 'commands/root.go')
-rw-r--r-- | commands/root.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/commands/root.go b/commands/root.go index 3438d15c..387c6342 100644 --- a/commands/root.go +++ b/commands/root.go @@ -5,10 +5,11 @@ import ( "fmt" "os" + "github.com/spf13/cobra" + "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" - "github.com/spf13/cobra" ) const rootCommandName = "git-bug" @@ -37,6 +38,7 @@ the same git remote your are already using to collaborate with other peoples. } }, + SilenceUsage: true, DisableAutoGenTag: true, // Custom bash code to connect the git completion for "git bug" to the @@ -58,12 +60,12 @@ func Execute() { func loadRepo(cmd *cobra.Command, args []string) error { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("Unable to get the current working directory: %q\n", err) + return fmt.Errorf("unable to get the current working directory: %q", err) } repo, err = repository.NewGitRepo(cwd, bug.Witnesser) if err == repository.ErrNotARepo { - return fmt.Errorf("%s must be run from within a git repo.\n", rootCommandName) + return fmt.Errorf("%s must be run from within a git repo", rootCommandName) } if err != nil { |