X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=utils.go;h=b47cd04aafdb93d5d23517ef167f307532705bdc;hb=c3c015d68a6f27bdb86c594ffbb481ee68f9e0c1;hp=d6324151d9af855fd29b397cf5d85af6f34d676e;hpb=e54535129f23970619042a328ad9a139bba21c5d;p=src%2Fxds%2Fxds-cli.git diff --git a/utils.go b/utils.go index d632415..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"); @@ -21,9 +21,11 @@ package main 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" ) @@ -83,6 +85,11 @@ func XdsServerIndexGet() int { return 0 } +// XdsServerComputeURL computes the URL used to access to XDS Server API +func XdsServerComputeURL(endURL string) string { + return "servers/" + strconv.Itoa(XdsServerIndexGet()) + endURL +} + // ProjectsListGet Get the list of existing projects func ProjectsListGet(prjs *[]xaapiv1.ProjectConfig) error { var data []byte @@ -109,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") +}