Commit f5bb2b11 by bergquist

feat(cli): improve error handling for missing plugin dir

parent 8da702c2
...@@ -11,6 +11,7 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C ...@@ -11,6 +11,7 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C
cmd := &contextCommandLine{context} cmd := &contextCommandLine{context}
if err := command(cmd); err != nil { if err := command(cmd); err != nil {
log.Error("\nError: ")
log.Errorf("%s\n\n", err) log.Errorf("%s\n\n", err)
cmd.ShowHelp() cmd.ShowHelp()
......
...@@ -28,7 +28,15 @@ func validateInput(c CommandLine, pluginFolder string) error { ...@@ -28,7 +28,15 @@ func validateInput(c CommandLine, pluginFolder string) error {
} }
fileInfo, err := os.Stat(pluginDir) fileInfo, err := os.Stat(pluginDir)
if err != nil && !fileInfo.IsDir() { if err != nil {
if err = os.MkdirAll(pluginDir, os.ModePerm); err != nil {
return errors.New("path is not a directory")
}
return nil
}
if !fileInfo.IsDir() {
return errors.New("path is not a directory") return errors.New("path is not a directory")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment