Beispiel #1
0
func (a *App) formattedEnv(wholeEnv map[string]string, key string) *tablewriter.Table {
	var elems [][]string

	if key == "" {
		for k, v := range wholeEnv {
			elems = append(elems, []string{k, v})
		}
	} else {
		elems = [][]string{[]string{key, wholeEnv[key]}}
	}

	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"Key", "Value"})
	table.SetBorder(false)
	table.AppendBulk(elems)

	return table
}
Beispiel #2
0
func TableizeTeams(teams []Team, defaultTeamId string) *tablewriter.Table {
	var elems [][]string

	for i, t := range teams {
		isDefault := ""

		if defaultTeamId == t.Id {
			isDefault = "*"
		}

		elems = append(elems, []string{fmt.Sprintf("%d", i+1), t.Name, isDefault})
	}

	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"No.", "Team", "Default"})
	table.SetBorder(false)
	table.AppendBulk(elems)

	return table
}
Beispiel #3
0
func TableizeVersions(versions []Version) *tablewriter.Table {
	var elems [][]string

	for i, v := range versions {
		currentlyDeployed := ""

		if v.CurrentlyDeployed {
			currentlyDeployed = "*"
		}

		elems = append(elems, []string{fmt.Sprintf("%d", i+1), v.Ref, v.HumanizedCreatedAt(), currentlyDeployed})
	}

	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"No.", "Ref", "Saved At", "Deployed"})
	table.SetBorder(false)
	table.AppendBulk(elems)

	return table
}