Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a3ff86e

Browse files
author
Sandy
authored
Merge pull request #11 from openset/develop
Add: leetcode version
2 parents ec2eb24 + 241c5e6 commit a3ff86e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎internal/base/base.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (c *Command) Name() string {
2828
func (c *Command) Usage() {
2929
fmt.Printf("usage: %s %s\n", CmdName, c.UsageLine)
3030
fmt.Printf("Run '%s help %s' for details.\n", CmdName, c.Name())
31-
os.Exit(0)
31+
Exit()
3232
}
3333

3434
func Usage() {
@@ -42,4 +42,9 @@ func Usage() {
4242
fmt.Println()
4343
fmt.Printf(`Use "%s help <command>" for more information about a command.`, CmdName)
4444
fmt.Println()
45+
Exit()
46+
}
47+
48+
func Exit() {
49+
os.Exit(0)
4550
}

‎main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@ func main() {
2424
if flag.NArg() < 1 {
2525
flag.Usage()
2626
}
27+
args := flag.Args()
28+
cmdName := args[0]
29+
for _, cmd := range base.Commands {
30+
if cmd.Name() == cmdName {
31+
cmd.Run(cmd, args[1:])
32+
base.Exit()
33+
}
34+
}
35+
fmt.Printf("%s %s: unknown command\n", base.CmdName, cmdName)
36+
fmt.Printf("Run '%s help' for usage.\n", base.CmdName)
2737
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /