Skip to content

Commit 4d33a57

Browse files
committed
Add a clear warning when the user is not runing koyeb login in a terminal
1 parent 549badc commit 4d33a57

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require (
2525

2626
require (
2727
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
28+
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 // indirect
2829
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
2930
github.com/chzyer/readline v1.5.1 // indirect
3031
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN
4444
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
4545
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
4646
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
47+
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 h1:axBiC50cNZOs7ygH5BgQp4N+aYrZ2DNpWZ1KG3VOSOM=
48+
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2/go.mod h1:jnzFpU88PccN/tPPhCpnNU8mZphvKxYM9lLNkd8e+os=
4749
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
4850
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
4951
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=

pkg/koyeb/login.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77

8+
termutil "github.com/andrew-d/go-termutil"
89
"github.com/manifoldco/promptui"
910
homedir "github.com/mitchellh/go-homedir"
1011
log "github.com/sirupsen/logrus"
@@ -26,6 +27,10 @@ func Login(cmd *cobra.Command, args []string) error {
2627
}
2728
viper.SetConfigFile(configPath)
2829

30+
if !termutil.Isatty(os.Stdin.Fd()) {
31+
log.Fatalf("Unable to read from stdin, please launch the command in interactive mode")
32+
}
33+
2934
writeFileMessage := fmt.Sprintf("Do you want to create a new configuration file in (%s)", configPath)
3035
if _, err := os.Stat(configPath); !errors.Is(err, os.ErrNotExist) {
3136
writeFileMessage = fmt.Sprintf("Do you want to update configuration file (%s)", configPath)

0 commit comments

Comments
 (0)