Beispiel #1
0
func (c *Command) PrintResult(result string, err error) {
	if err == nil {
		fmt.Fprintln(os.Stdout, result)
		os.Exit(EXIT_SUCCESS)
	} else if api.IsAuthenticationError(err) {
		fmt.Fprintln(os.Stderr, `{"msg":"Authentication failed!"}`)
		os.Exit(EXIT_AUTHENTICATION_ERROR)
	} else {
		fmt.Fprintln(os.Stderr, GetErrorJson(err))
		os.Exit(EXIT_SUCCESS_ERROR)
	}
}
Beispiel #2
0
func (c *Command) PrintResult(result string, err error) {
	if err == nil {
		fmt.Fprintln(os.Stdout, result)
		os.Exit(EXIT_SUCCESS)
	} else if api.IsInvalidConfig(err) {
		fmt.Printf(`coscale-cli could not find valid credentials.

%s
`, authInfo)
		os.Exit(EXIT_FLAG_ERROR)
	} else if api.IsAuthenticationError(err) {
		fmt.Fprintln(os.Stderr, `{"msg":"Authentication failed!"}`)
		os.Exit(EXIT_AUTHENTICATION_ERROR)
	} else {
		fmt.Fprintln(os.Stderr, GetErrorJson(err))
		os.Exit(EXIT_SUCCESS_ERROR)
	}
}