From 15b6958248486766e70bc032563f237019053707 Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Sun, 5 Jan 2025 09:53:56 +0100 Subject: [PATCH] switch option update cmd --- plan/command/update.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plan/command/update.go b/plan/command/update.go index 7c9576b..3ff6c5a 100644 --- a/plan/command/update.go +++ b/plan/command/update.go @@ -37,10 +37,20 @@ func NewUpdateArgs() UpdateArgs { } func (ua UpdateArgs) Parse(main []string, fields map[string]string) (Command, error) { - if len(main) < 2 || main[0] != "update" { + if len(main) < 2 { return nil, ErrWrongCommand } - localID, err := strconv.Atoi(main[1]) + aliases := []string{"u", "update"} + var localIDStr string + switch { + case slices.Contains(aliases, main[0]): + localIDStr = main[1] + case slices.Contains(aliases, main[1]): + localIDStr = main[0] + default: + return nil, ErrWrongCommand + } + localID, err := strconv.Atoi(localIDStr) if err != nil { return nil, fmt.Errorf("not a local id: %v", main[1]) }