Example #1
0
// Load tries to read the global configurations from flag, env or a toml file.
func Load(args []string) (*Config, []string, error) {
	conf := new(Config)
	if err := loader.Load(conf, args); err != nil {
		panic(err)
	}

	remainingArgs := loader.ExcludeArgs(conf, args)

	conf.Ui = &cli.BasicUi{
		Reader:      os.Stdin,
		Writer:      os.Stdout,
		ErrorWriter: os.Stderr,
	}

	return conf, remainingArgs, nil
}
Example #2
0
// NewCommand returns a new instance of GceImages
func NewCommand(args []string) (*GceCommand, []string, error) {
	var conf struct {
		// just so we can use the Env and TOML loader more efficiently with out
		// any complex hacks
		Gce GCEConfig
	}

	if err := loader.Load(&conf, args); err != nil {
		return nil, nil, err
	}

	gceImages, err := New(&conf.Gce)
	if err != nil {
		return nil, nil, err
	}

	remainingArgs := loader.ExcludeArgs(&conf, args)
	return &GceCommand{
		GceImages: gceImages,
	}, remainingArgs, nil
}