From bdf8523dc0d8cbd9f29e62fa8605b5bd5292828e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 27 Mar 2019 21:54:58 +0100 Subject: [PATCH] commands: only return the error (not the function help) when no identity is set ... to avoid misleading a user into thinking the usage was incorrect --- commands/root.go | 4 +++- identity/identity.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/root.go b/commands/root.go index adbf51d97fb6febc0fe993cff0ea2bf1216b163b..3438d15ccb50997df03e519cf9fa4b1c742a6023 100644 --- a/commands/root.go +++ b/commands/root.go @@ -88,7 +88,9 @@ func loadRepoEnsureUser(cmd *cobra.Command, args []string) error { } if !set { - return identity.ErrNoIdentitySet + // Print the error directly to not confuse a user + _, _ = fmt.Fprintln(os.Stderr, identity.ErrNoIdentitySet.Error()) + os.Exit(-1) } return nil diff --git a/identity/identity.go b/identity/identity.go index 3dddfaec42a8b7916b5b70a5adddeeadeaa4dbe6..be3c16ecc098c771efb473e88a7ca87105788a36 100644 --- a/identity/identity.go +++ b/identity/identity.go @@ -25,7 +25,7 @@ const idLength = 40 const humanIdLength = 7 var ErrNonFastForwardMerge = errors.New("non fast-forward identity merge") -var ErrNoIdentitySet = errors.New("user identity first needs to be created using \"git bug user create\" or \"git bug user adopt\"") +var ErrNoIdentitySet = errors.New("to interact with bugs, an identity first needs to be created using \"git bug user create\" or \"git bug user adopt\"") var ErrMultipleIdentitiesSet = errors.New("multiple user identities set") var _ Interface = &Identity{}