X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=utils.go;h=b47cd04aafdb93d5d23517ef167f307532705bdc;hb=93f0511c5e5a215d27025510cf430c49ecf506cc;hp=65b67d3fc78ee79080b3df544b8030329999d0a2;hpb=397a6038d7d88d21c8577f1c7267849ba5814080;p=src%2Fxds%2Fxds-cli.git diff --git a/utils.go b/utils.go index 65b67d3..b47cd04 100644 --- a/utils.go +++ b/utils.go @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 "IoT.bzh" + * Copyright (C) 2017-2018 "IoT.bzh" * Author Sebastien Douheret * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,9 +22,10 @@ import ( "encoding/json" "fmt" "strconv" + "strings" + "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xaapiv1" "github.com/franciscocpg/reflectme" - "github.com/iotbzh/xds-agent/lib/xaapiv1" "github.com/urfave/cli" ) @@ -115,3 +116,12 @@ func GetID(ctx *cli.Context) string { } return id } + +// Confirm Return true when user answer 'y' or 'yes' to a question +func Confirm(question string) bool { + var answer string + fmt.Print(question) + fmt.Scanln(&answer) + ans := strings.ToLower(strings.TrimSpace(answer)) + return (ans == "y" || ans == "yes") +}