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 f732ee2

Browse files
author
Openset
committed
Add: CmdUpdate
1 parent b749f87 commit f732ee2

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎internal/update/update.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package update
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
7+
"github.com/openset/leetcode/internal/base"
8+
)
9+
10+
var CmdUpdate = &base.Command{
11+
Run: runUpdate,
12+
UsageLine: "update",
13+
Short: "update self",
14+
Long: "automates testing the packages.",
15+
}
16+
17+
func runUpdate(cmd *base.Command, args []string) {
18+
if len(args) != 0 {
19+
cmd.Usage()
20+
}
21+
err := exec.Command("go", "get", "-u", "github.com/openset/leetcode").Run()
22+
base.CheckErr(err)
23+
c := exec.Command(base.CmdName, "version")
24+
c.Stdout = os.Stdout
25+
c.Stderr = os.Stderr
26+
err = c.Run()
27+
base.CheckErr(err)
28+
}

‎main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import (
88
"github.com/openset/leetcode/internal/base"
99
"github.com/openset/leetcode/internal/help"
1010
"github.com/openset/leetcode/internal/readme"
11+
"github.com/openset/leetcode/internal/update"
1112
"github.com/openset/leetcode/internal/version"
1213
)
1314

1415
func init() {
1516
base.Commands = []*base.Command{
1617
readme.CmdReadme,
18+
update.CmdUpdate,
1719
version.CmdVersion,
1820
help.CmdHelp,
1921
}

0 commit comments

Comments
(0)

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