Usage: "project id",
EnvVar: "XDS_PROJECT_ID",
},
+ cli.BoolFlag{
+ Name: "force, f",
+ Usage: "remove confirmation prompt before removal",
+ },
},
},
{
return cli.NewExitError("id parameter or option must be set", 1)
}
+ if !ctx.Bool("force") {
+ if !Confirm("Do you permanently remove project id '" + id + "' [yes/No] ? ") {
+ return nil
+ }
+ }
+
if err := HTTPCli.Delete("/projects/"+id, &res); err != nil {
return cli.NewExitError(err, 1)
}
Usage: "sdk id to un-install",
EnvVar: "XDS_SDK_ID",
},
+ cli.BoolFlag{
+ Name: "force, f",
+ Usage: "remove confirmation prompt before removal",
+ },
},
},
{
return cli.NewExitError("id parameter or option must be set", 1)
}
+ if !ctx.Bool("force") {
+ if !Confirm("Do you permanently remove SDK id '" + id + "' [yes/No] ? ") {
+ return nil
+ }
+ }
+
delSdk := xaapiv1.SDK{}
url := XdsServerComputeURL("/sdks/" + id)
if err := HTTPCli.Delete(url, &delSdk); err != nil {
"encoding/json"
"fmt"
"strconv"
+ "strings"
"github.com/franciscocpg/reflectme"
"github.com/iotbzh/xds-agent/lib/xaapiv1"
}
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")
+}