// 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
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.HasPrefix(refID, ID)
+}