示例#1
0
func KeysRemoveAutoComplete(c *cli.Context) error {
	keys, err := api.KeysList()
	if err == nil {

		for _, key := range keys {
			fmt.Println(key.Name)
		}
	}

	return nil
}
示例#2
0
文件: remove.go 项目: yannski/cli
func keyByName(name string) (*api.Key, error) {
	keys, err := api.KeysList()
	if err != nil {
		return nil, errgo.Mask(err)
	}
	for _, k := range keys {
		if k.Name == name {
			return &k, nil
		}
	}
	return nil, errgo.New("no such key")
}
示例#3
0
文件: list.go 项目: yannski/cli
func List() error {
	keys, err := api.KeysList()
	if err != nil {
		return errgo.Mask(err)
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetColWidth(60)
	t.SetHeader([]string{"Name", "Content"})

	for _, k := range keys {
		t.Append([]string{k.Name, k.Content[0:20] + "..." + k.Content[len(k.Content)-30:]})
	}

	t.Render()
	return nil
}