本文整理汇总了Golang中github.com/juju/juju/cmd/output.Wrapper.SetColumnAlignRight方法的典型用法代码示例。如果您正苦于以下问题:Golang Wrapper.SetColumnAlignRight方法的具体用法?Golang Wrapper.SetColumnAlignRight怎么用?Golang Wrapper.SetColumnAlignRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/cmd/output.Wrapper
的用法示例。
在下文中一共展示了Wrapper.SetColumnAlignRight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: formatCloudsTabular
// formatCloudsTabular writes a tabular summary of cloud information.
func formatCloudsTabular(writer io.Writer, value interface{}) error {
clouds, ok := value.(*cloudList)
if !ok {
return errors.Errorf("expected value of type %T, got %T", clouds, value)
}
tw := output.TabWriter(writer)
w := output.Wrapper{tw}
w.Println("Cloud", "Regions", "Default", "Type", "Description")
w.SetColumnAlignRight(1)
cloudNamesSorted := func(someClouds map[string]*cloudDetails) []string {
// For tabular we'll sort alphabetically, user clouds last.
var names []string
for name, _ := range someClouds {
names = append(names, name)
}
sort.Strings(names)
return names
}
printClouds := func(someClouds map[string]*cloudDetails, color *ansiterm.Context) {
cloudNames := cloudNamesSorted(someClouds)
for _, name := range cloudNames {
info := someClouds[name]
defaultRegion := ""
if len(info.Regions) > 0 {
defaultRegion = info.RegionsMap[info.Regions[0].Key.(string)].Name
}
description := info.CloudDescription
if len(description) > 40 {
description = description[:39]
}
w.PrintColor(color, name)
w.Println(len(info.Regions), defaultRegion, info.CloudType, description)
}
}
printClouds(clouds.public, nil)
printClouds(clouds.builtin, nil)
printClouds(clouds.personal, ansiterm.Foreground(ansiterm.BrightBlue))
w.Println("\nTry 'list-regions <cloud>' to see available regions.")
w.Println("'show-cloud <cloud>' or 'regions --format yaml <cloud>' can be used to see region endpoints.")
w.Println("'add-cloud' can add private clouds or private infrastructure.")
w.Println("Update the known public clouds with 'update-clouds'.")
tw.Flush()
return nil
}