From d78842a1f493b49418986144319db82bfb6d24d5 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 16 Oct 2024 11:44:49 +0700 Subject: [PATCH] fix: Edit and Del actionsEdit check for 3 sections not 2. Del append to remove item updated. --- .clasp.json | 2 +- .claspall.json | 1 - claspall.go | 8 ++++---- command.go | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 .claspall.json diff --git a/.clasp.json b/.clasp.json index 1e8c2d5..1830b98 100644 --- a/.clasp.json +++ b/.clasp.json @@ -1,4 +1,4 @@ -{ + "scriptId": "1_hg5Lj-lOXbZMm60FizXSEZBmYN27-ozK-JOX4fRmEWX9TQBtp1S6wZt", "rootDir": "/home/yagi/work/projects/AppsScript/CLASPALL/testProj" } \ No newline at end of file diff --git a/.claspall.json b/.claspall.json deleted file mode 100644 index 0637a08..0000000 --- a/.claspall.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/claspall.go b/claspall.go index 4f2d41a..6175fbe 100644 --- a/claspall.go +++ b/claspall.go @@ -25,9 +25,9 @@ func (files *Files) add(name string, id string) { } func (files *Files) validateIndex(index int) error { - fmt.Println("validate index") + fmt.Println("validating index") if index < 0 || index > len(*files) { - err := errors.New("Error: Invalid index") + err := errors.New("💥 Error: Invalid index") log.Fatalln(err) } return nil @@ -40,8 +40,8 @@ func (files *Files) delete(num int) error { if err := f.validateIndex(idx); err != nil { return err } - // TODO There must be a better way to update files. - *files = append(f[:idx], f[:idx+1]...) + + *files = append(f[:idx], f[idx+1:]...) return nil } diff --git a/command.go b/command.go index b96a7c5..4ad5d7e 100644 --- a/command.go +++ b/command.go @@ -92,7 +92,7 @@ func (cf CmdFlags) Execute(files *Files) { case cf.Add != "": parts := strings.SplitN(cf.Add, ":", 2) if len(parts) != 2 { - fmt.Println("Error, invalid format for Add.") + fmt.Println("💥 Error, invalid format for Add.") fmt.Print(FlagUsage.Add) os.Exit(1) } @@ -101,15 +101,15 @@ func (cf CmdFlags) Execute(files *Files) { case cf.Edit != "": parts := strings.SplitN(cf.Edit, ":", 3) - if len(parts) != 2 { - fmt.Println("Error, invalid format for Edit.") + if len(parts) != 3 { + fmt.Println("💥 Error, invalid format for Edit.") fmt.Print(FlagUsage.Edit) os.Exit(1) } line, err := strconv.Atoi(parts[0]) if err != nil { - fmt.Println("Error, invalid line number to edit") + fmt.Println("💥 Error, invalid line number to edit") fmt.Print(FlagUsage.Edit) os.Exit(1) }