Skip to content

Commit

Permalink
✨ exec: test: add skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
budougumi0617 committed Sep 23, 2020
1 parent 4ed7f66 commit dd9c0d7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func main() {
}
ctx := context.Background()
args := flag.Args()
// FIXME: confirm each command condition
if len(args) != 2 {
fmt.Printf("invalid sub command %q\n", args)
os.Exit(1)
Expand Down Expand Up @@ -66,8 +67,28 @@ func main() {
}
// test Test question by id [aliases: t]
case TEST:
id, err := strconv.Atoi(args[1])
if err != nil || id == 0 {
fmt.Printf("cannot get id: %q\n", args[1])
os.Exit(1)
}
// TODO: Get auth information
if err := leetgode.TestCmd(ctx, id); err != nil {
fmt.Printf("failed TestCmd(ctx, %q): %v\n", args[1], err)
os.Exit(1)
}
// exec Submit solution [aliases: x]
case EXEC:
id, err := strconv.Atoi(args[1])
if err != nil || id == 0 {
fmt.Printf("cannot get id: %q\n", args[1])
os.Exit(1)
}
// TODO: Get auth information
if err := leetgode.ExecCmd(ctx, id); err != nil {
fmt.Printf("failed ExecCmd(ctx, %q): %v\n", args[1], err)
os.Exit(1)
}
default:
fmt.Printf("invalid sub command %q\n", sub)
os.Exit(1)
Expand Down
7 changes: 7 additions & 0 deletions exec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package leetgode

import "context"

func ExecCmd(ctx context.Context, id int) error {
return nil
}
7 changes: 7 additions & 0 deletions test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package leetgode

import "context"

func TestCmd(ctx context.Context, id int) error {
return nil
}

0 comments on commit dd9c0d7

Please sign in to comment.