fix(cli): improve logging when folders does not exists

This commit is contained in:
bergquist
2016-03-07 16:41:22 +01:00
parent 7ef62d28a5
commit 1a6af064b0
2 changed files with 12 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package commands
import (
"errors"
"fmt"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
@@ -14,11 +15,11 @@ var validateLsCommmand = func(pluginDir string) error {
return errors.New("missing path flag")
}
log.Info("plugindir: " + pluginDir + "\n")
log.Debug("plugindir: " + pluginDir + "\n")
pluginDirInfo, err := s.IoHelper.Stat(pluginDir)
if err != nil {
return errors.New("missing path flag")
return fmt.Errorf("error: %s", err)
}
if pluginDirInfo.IsDir() == false {
@@ -34,8 +35,14 @@ func lsCommand(c CommandLine) error {
return err
}
for _, plugin := range ls_getPlugins(pluginDir) {
log.Infof("plugin: %s @ %s \n", plugin.Name, plugin.Info.Version)
plugins := ls_getPlugins(pluginDir)
if len(plugins) > 0 {
log.Info("installed plugins:\n")
}
for _, plugin := range plugins {
log.Infof("%s @ %s \n", plugin.Id, plugin.Info.Version)
}
return nil