diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-02-23 22:13:22 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-02-23 22:13:22 +0100 |
commit | 2231e3eae86c5e3ae05e30f667d331f5875c7884 (patch) | |
tree | 44c56c9d8b3bb4c6cbee26bedc2c0aec9d9bb5f1 /utils.go | |
parent | 84273d6128b7c3c9d31c2f3a1453107a78e949a9 (diff) |
Added target and terminal supportv1.1.0
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'utils.go')
-rw-r--r-- | utils.go | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -123,7 +123,15 @@ func LogPost(format string, data interface{}) { // GetID Return a string ID set with --id option or as simple parameter func GetID(ctx *cli.Context) string { - id := ctx.String("id") + return GetIDName(ctx, "id") +} + +// GetIDName Return a string ID set with --XXX option or as simple parameter +func GetIDName(ctx *cli.Context, idName string) string { + if idName == "" { + return "" + } + id := ctx.String(idName) idArgs := ctx.Args().First() if id == "" && idArgs != "" { id = idArgs @@ -139,3 +147,8 @@ func Confirm(question string) bool { ans := strings.ToLower(strings.TrimSpace(answer)) return (ans == "y" || ans == "yes") } + +// compareID Compare an ID to a reference ID +func compareID(refID, ID string) bool { + return refID != "" && ID != "" && strings.Contains(refID, ID) +} |