本文整理匯總了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
}