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

This commit is contained in:
bergquist 2016-03-11 14:11:25 +01:00
parent 8da702c2e7
commit f5bb2b11e5
2 changed files with 10 additions and 1 deletions

View File

@ -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()

View File

@ -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")
} }