Beispiel #1
0
func AppConfigPath(cmd *cobra.Command) (string, error) {
	if configFile, err := cmd.Flags().GetString("filename"); err == nil && configFile != "" {
		fmt.Printf("using config file %s\n", configFile)
		return filepath.EvalSymlinks(configFile)
	}

	return filepath.EvalSymlinks(".ranch.yaml")
}
Beispiel #2
0
func AppName(cmd *cobra.Command) (string, error) {
	// use flag
	if app := cmd.Flag("app").Value.String(); app != "" {
		return app, nil
	}

	// fall back to config
	if config, err := LoadAppConfig(cmd); err == nil {
		return config.AppName, nil
	}

	// fall back to directory name
	if appDir, err := AppDir(cmd); err != nil {
		return "", err
	} else {
		return path.Base(appDir), nil
	}
}