Пример #1
0
func initClient(c *cli.Context) error {
	cfgFile := c.GlobalString("config")
	if cfgFile != "" {
		client, _ = sfapi.NewFromConfig(cfgFile)
		conf, _ := sfapi.ProcessConfig(cfgFile)
		client.Config = &conf
	} else {
		client, _ = sfapi.New()
	}
	updateLogLevel(c)
	return nil
}
Пример #2
0
package sfcli

import (
	"fmt"
	log "github.com/Sirupsen/logrus"
	"github.com/codegangsta/cli"
	"github.com/solidfire/solidfire-docker-driver/sfapi"
	"strings"
	"unicode/utf8"
)

var client, _ = sfapi.New()

// cmdNofFound routines borrowed from rackspace/rack
// https://github.com/rackspace/rack/blob/master/commandsuggest.go
func cmdNotFound(c *cli.Context, command string) {
	app := c.App
	var choices []string
	for _, cmd := range app.Commands {
		choices = append(choices, cmd.Name)
	}
	//choices := globalOptionsNames(app)
	currentMin := 50
	bestSuggestion := ""
	for _, choice := range choices {
		similarity := levenshtein(choice, command)
		tmpMin := min(currentMin, similarity)
		if tmpMin < currentMin {
			bestSuggestion = choice
			currentMin = tmpMin
		}