Example #1
0
func (ui terminalUI) ShowConfiguration(config configuration.Reader) {
	if config.HasAPIEndpoint() {
		ui.Say("API endpoint: %s (API version: %s)",
			EntityNameColor(config.ApiEndpoint()),
			EntityNameColor(config.ApiVersion()))
	}

	if !config.IsLoggedIn() {
		ui.Say(NotLoggedInText())
		return
	} else {
		ui.Say("User:         %s", EntityNameColor(config.UserEmail()))
	}

	if !config.HasOrganization() && !config.HasSpace() {
		command := fmt.Sprintf("%s target -o ORG -s SPACE", cf.Name())
		ui.Say("No org or space targeted, use '%s'", CommandColor(command))
		return
	}

	if config.HasOrganization() {
		ui.Say("Org:          %s", EntityNameColor(config.OrganizationFields().Name))
	} else {
		command := fmt.Sprintf("%s target -o Org", cf.Name())
		ui.Say("Org:          No org targeted, use '%s'", CommandColor(command))
	}

	if config.HasSpace() {
		ui.Say("Space:        %s", EntityNameColor(config.SpaceFields().Name))
	} else {
		command := fmt.Sprintf("%s target -s SPACE", cf.Name())
		ui.Say("Space:        No space targeted, use '%s'", CommandColor(command))
	}
}
Example #2
0
File: ui.go Project: jacopen/cli
func (ui terminalUI) ShowConfiguration(config configuration.Reader) {
	table := NewTable(ui, []string{"", ""})
	if config.HasAPIEndpoint() {
		table.Add(
			T("API endpoint:"),
			T("{{.ApiEndpoint}} (API version: {{.ApiVersionString}})",
				map[string]interface{}{
					"ApiEndpoint":      EntityNameColor(config.ApiEndpoint()),
					"ApiVersionString": EntityNameColor(config.ApiVersion()),
				}),
		)
	}

	if !config.IsLoggedIn() {
		table.Print()
		ui.Say(NotLoggedInText())
		return
	} else {
		table.Add(
			T("User:"******"%s target -o ORG -s SPACE", cf.Name())
		ui.Say(T("No org or space targeted, use '{{.CFTargetCommand}}'",
			map[string]interface{}{
				"CFTargetCommand": CommandColor(command),
			}))
		return
	}

	if config.HasOrganization() {
		table.Add(
			T("Org:"),
			EntityNameColor(config.OrganizationFields().Name),
		)
	} else {
		command := fmt.Sprintf("%s target -o Org", cf.Name())
		table.Add(
			T("Org:"),
			T("No org targeted, use '{{.CFTargetCommand}}'",
				map[string]interface{}{
					"CFTargetCommand": CommandColor(command),
				}),
		)
	}

	if config.HasSpace() {
		table.Add(
			T("Space:"),
			EntityNameColor(config.SpaceFields().Name),
		)
	} else {
		command := fmt.Sprintf("%s target -s SPACE", cf.Name())
		table.Add(
			T("Space:"),
			T("No space targeted, use '{{.CFTargetCommand}}'", map[string]interface{}{"CFTargetCommand": CommandColor(command)}),
		)
	}

	table.Print()
}
Example #3
0
File: ui.go Project: GABONIA/cli
func (ui terminalUI) ShowConfiguration(config configuration.Reader) {
	if config.HasAPIEndpoint() {
		ui.Say(T("API endpoint: {{.ApiEndpoint}} (API version: {{.ApiVersionString}})", map[string]interface{}{"ApiEndpoint": EntityNameColor(config.ApiEndpoint()), "ApiVersionString": EntityNameColor(config.ApiVersion())}))
	}

	if !config.IsLoggedIn() {
		ui.Say(NotLoggedInText())
		return
	} else {
		ui.Say(T("User:         {{.UserEmail}}", map[string]interface{}{"UserEmail": EntityNameColor(config.UserEmail())}))
	}

	if !config.HasOrganization() && !config.HasSpace() {
		command := fmt.Sprintf("%s target -o ORG -s SPACE", cf.Name())
		ui.Say(T("No org or space targeted, use '{{.CFTargetCommand}}'", map[string]interface{}{"CFTargetCommand": CommandColor(command)}))
		return
	}

	if config.HasOrganization() {
		ui.Say(T("Org:          {{.OrganizationName}}", map[string]interface{}{"OrganizationName": EntityNameColor(config.OrganizationFields().Name)}))
	} else {
		command := fmt.Sprintf("%s target -o Org", cf.Name())
		ui.Say(T("Org:          No org targeted, use '{{.CFTargetCommand}}'", map[string]interface{}{"CFTargetCommand": CommandColor(command)}))
	}

	if config.HasSpace() {
		ui.Say(T("Space:        {{.SpaceName}}", map[string]interface{}{"SpaceName": EntityNameColor(config.SpaceFields().Name)}))
	} else {
		command := fmt.Sprintf("%s target -s SPACE", cf.Name())
		ui.Say(T("Space:        No space targeted, use '{{.CFTargetCommand}}'", map[string]interface{}{"CFTargetCommand": CommandColor(command)}))
	}
}