diff options
author | Amine <hilalyamine@gmail.com> | 2019-11-26 22:05:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-26 22:05:32 +0100 |
commit | 5207fb41091a382cc8c0c8db2dc6f7c10bbb8a77 (patch) | |
tree | a85ca33f431caa2bb06ad1dc1a77965ce9fa1feb /bridge/gitlab/config.go | |
parent | 26a62692415868dab906bc702504e83532cb09b9 (diff) | |
parent | 1a1e313f3028243680c29520d96f722092a2bd38 (diff) | |
download | git-bug-5207fb41091a382cc8c0c8db2dc6f7c10bbb8a77.tar.gz |
Merge pull request #263 from MichaelMure/configure-cleanup
github: tiny cleanups of the configurator
Diffstat (limited to 'bridge/gitlab/config.go')
-rw-r--r-- | bridge/gitlab/config.go | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go index 5c6ccb0e..6b85e8cb 100644 --- a/bridge/gitlab/config.go +++ b/bridge/gitlab/config.go @@ -8,13 +8,16 @@ import ( "regexp" "strconv" "strings" + "time" + text "github.com/MichaelMure/go-term-text" "github.com/pkg/errors" "github.com/xanzy/go-gitlab" "github.com/MichaelMure/git-bug/bridge/core" "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/repository" + "github.com/MichaelMure/git-bug/util/colors" ) var ( @@ -135,17 +138,31 @@ func promptTokenOptions(repo repository.RepoCommon) (*core.Token, error) { return nil, err } + if len(tokens) == 0 { + token, err := promptToken() + if err != nil { + return nil, err + } + return core.LoadOrCreateToken(repo, target, token) + } + fmt.Println() - fmt.Println("[1]: user provided token") - - if len(tokens) > 0 { - fmt.Println("known tokens for Gitlab:") - for i, token := range tokens { - if token.Target == target { - fmt.Printf("[%d]: %s\n", i+2, token.ID()) - } + fmt.Println("[1]: enter my token") + + fmt.Println() + fmt.Println("Existing tokens for Gitlab:") + for i, token := range tokens { + if token.Target == target { + fmt.Printf("[%d]: %s => %s (%s)\n", + i+2, + colors.Cyan(token.ID().Human()), + text.TruncateMax(token.Value, 10), + token.CreateTime.Format(time.RFC822), + ) } } + + fmt.Println() fmt.Print("Select option: ") line, err := bufio.NewReader(os.Stdin).ReadString('\n') @@ -251,7 +268,7 @@ func promptURL(remotes map[string]string) (string, error) { } url := strings.TrimSpace(line) - if line == "" { + if url == "" { fmt.Println("URL is empty") continue } |