From f3d8da10750d58fce482042cff87455a1e6f36e0 Mon Sep 17 00:00:00 2001 From: Amine Hilaly Date: Mon, 2 Sep 2019 09:24:53 +0200 Subject: bridge/core: add tokenStdin field to bridgeParams commands: move tokenStdin handling logic to bridge.Configure --- bridge/github/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'bridge/github/config.go') diff --git a/bridge/github/config.go b/bridge/github/config.go index bc4911e0..16abfa09 100644 --- a/bridge/github/config.go +++ b/bridge/github/config.go @@ -45,7 +45,7 @@ func (g *Github) Configure(repo repository.RepoCommon, params core.BridgeParams) var owner string var project string - if params.Token != "" && + if (params.Token != "" || params.TokenStdin) && (params.URL == "" && (params.Project == "" || params.Owner == "")) { return nil, fmt.Errorf("you must provide a project URL or Owner/Name to configure this bridge with a token") } @@ -91,6 +91,13 @@ func (g *Github) Configure(repo repository.RepoCommon, params core.BridgeParams) if params.Token != "" { token = params.Token + } else if params.TokenStdin { + reader := bufio.NewReader(os.Stdin) + token, err = reader.ReadString('\n') + if err != nil { + return nil, fmt.Errorf("reading from stdin: %v", err) + } + token = strings.TrimSuffix(token, "\n") } else { token, err = promptTokenOptions(owner, project) if err != nil { -- cgit