Skip to content

Commit

Permalink
Fix: when unknown command
Browse files Browse the repository at this point in the history
  • Loading branch information
utokato committed Aug 27, 2024
1 parent 90ee3b5 commit ce10bda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
plsVersion = "0.0.2"
plsVersion = "1.0.1"
dir = ".commands"
)

Expand All @@ -33,7 +33,8 @@ var (
// Execute all api entry.
func Execute() {
if err := root.Execute(); err != nil {
panic(err)
// ignore error
// _ = root.Help()
}
}

Expand All @@ -42,7 +43,7 @@ func init() {
if !fileExist(dirPath) {
err := makeCmdDir(dirPath)
if err != nil {
panic(err)
fmt.Println("[sorry] failed to create command dir")
}
}

Expand Down
5 changes: 1 addition & 4 deletions cmd/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@ func fileExist(path string) bool {
}

func makeCmdDir(dir string) error {
if _, err := os.Stat(dir); err != nil && !os.IsExist(err) {
return os.Mkdir(dir, 0755)
}
return nil
return os.MkdirAll(dir, 0755)
}

0 comments on commit ce10bda

Please sign in to comment.