Beispiel #1
0
func initI18nFunc() bool {
	config, err := configv3.LoadConfig()
	if err != nil {
		fmt.Println(FailureColor("FAILED"))
		fmt.Println("Error read/writing config: ", err.Error())
		os.Exit(1)
	}
	T = Init(config)
	return true
}
Beispiel #2
0
func executionWrapper(cmd flags.Commander, args []string) error {
	cfConfig, err := configv3.LoadConfig()
	if err != nil {
		return err
	}
	defer configv3.WriteConfig(cfConfig)

	if extendedCmd, ok := cmd.(commands.ExtendedCommander); ok {
		commandUI, err := ui.NewUI(cfConfig)
		if err != nil {
			return err
		}

		err = extendedCmd.Setup(cfConfig, commandUI)
		if err != nil {
			return handleError(err, commandUI)
		}
		return handleError(extendedCmd.Execute(args), commandUI)
	}

	return fmt.Errorf("command does not conform to ExtendedCommander")
}