diff options
author | Amine <hilalyamine@gmail.com> | 2019-09-06 23:03:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-06 23:03:27 +0200 |
commit | f90f3d6da911fc75742c1189966fe1a0116e65d4 (patch) | |
tree | 5d6af196a998c5186b08214e1f128b12ab6f1eb6 /commands | |
parent | 3ad2eeb5d07c14a039e0f0028b84033ff9b2c7db (diff) | |
parent | e5b33ca39c89c6e41bc6c29b8cf87dbae3287450 (diff) | |
download | git-bug-f90f3d6da911fc75742c1189966fe1a0116e65d4.tar.gz |
Merge pull request #216 from MichaelMure/cmd-silence
commands: silence usage when cobra RunE/PreRunE functions fail
Diffstat (limited to 'commands')
-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 { |