Ejemplo n.º 1
0
func (this *Alias) Run(args []string) (exitCode int) {
	cmdFlags := flag.NewFlagSet("alias", flag.ContinueOnError)
	cmdFlags.Usage = func() { this.Ui.Output(this.Help()) }
	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	aliases := ctx.AliasesWithValue()
	sortedNames := make([]string, 0, len(aliases))
	for name, _ := range aliases {
		sortedNames = append(sortedNames, name)
	}
	sort.Strings(sortedNames)

	lines := make([]string, 0, len(aliases)+1)
	header := "Alias|Command"
	lines = append(lines, header)
	for _, name := range sortedNames {
		lines = append(lines, fmt.Sprintf("%s|%s", name, aliases[name]))
	}

	fmt.Println(columnize.SimpleFormat(lines))

	return
}
Ejemplo n.º 2
0
func (this *Alias) Run(args []string) (exitCode int) {
	aliases := ctx.AliasesWithValue()
	sortedNames := make([]string, 0, len(aliases))
	for name, _ := range aliases {
		sortedNames = append(sortedNames, name)
	}
	sort.Strings(sortedNames)

	lines := make([]string, 0, len(aliases)+1)
	header := "Alias|Command"
	lines = append(lines, header)
	for _, name := range sortedNames {
		lines = append(lines, fmt.Sprintf("%s|%s", name, aliases[name]))
	}

	fmt.Println(columnize.SimpleFormat(lines))

	return
}