Example #1
0
func getClient() api.Client {
	if leoClient == (api.Client{}) {
		var errs []error

		config := config.GetConfig()

		errs, leoClient = api.NewClient(config.LinguaLeo.Email, config.LinguaLeo.Password)
		if errs != nil {
			log.Fatalf("%v \n", errs)
		}
	}
	return leoClient
}
Example #2
0
	home "github.com/mitchellh/go-homedir"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"gopkg.in/yaml.v2"
	"log"
	"os"
	"strings"
)

var initCmd = &cobra.Command{
	Use:   "init",
	Short: "Initialize configuration file",
	Run: func(cmd *cobra.Command, args []string) {
		var err error

		configuration := config.GetConfig()

		file := cfgFile

		if strings.TrimSpace(file) == "" {
			file = viper.ConfigFileUsed()
			if strings.TrimSpace(file) == "" {
				log.Fatal("Configuration file not found")
			}
		}
		file, err = home.Expand(file)
		if err != nil {
			log.Fatalln(err.Error())
		}

		reader := bufio.NewReader(os.Stdin)