Ejemplo n.º 1
0
Archivo: ui.go Proyecto: jasonkeene/cli
func (ui *terminalUI) ShowConfiguration(config coreconfig.Reader) error {
	var err error
	table := ui.Table([]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() {
		err = table.Print()
		if err != nil {
			return err
		}
		ui.Say(NotLoggedInText())
		return nil
	}

	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 nil
	}

	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)}),
		)
	}

	err = table.Print()
	if err != nil {
		return err
	}
	return nil
}