Skip to content

Commit

Permalink
fix: Edit and Del actionsEdit check for 3 sections not 2.
Browse files Browse the repository at this point in the history
Del append to remove item updated.
  • Loading branch information
Scott committed Oct 16, 2024
1 parent b24a471 commit d78842a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .clasp.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

"scriptId": "1_hg5Lj-lOXbZMm60FizXSEZBmYN27-ozK-JOX4fRmEWX9TQBtp1S6wZt",
"rootDir": "/home/yagi/work/projects/AppsScript/CLASPALL/testProj"
}
1 change: 0 additions & 1 deletion .claspall.json

This file was deleted.

8 changes: 4 additions & 4 deletions claspall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit d78842a

Please sign in to comment.