github.com/koron/hk@v0.0.0-20150303213137-b8aeaa3ab34c/regions.go (about) 1 package main 2 3 import ( 4 "os" 5 "text/tabwriter" 6 ) 7 8 var cmdRegions = &Command{ 9 Run: runRegions, 10 Usage: "regions", 11 Category: "misc", 12 Short: "list regions" + extra, 13 Long: ` 14 Lists regions. Shows the region name and description. 15 16 Examples: 17 18 $ hk regions 19 eu Europe 20 us United States 21 `, 22 } 23 24 func runRegions(cmd *Command, args []string) { 25 if len(args) != 0 { 26 cmd.PrintUsage() 27 os.Exit(2) 28 } 29 regions, err := client.RegionList(nil) 30 must(err) 31 32 w := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0) 33 defer w.Flush() 34 35 for _, r := range regions { 36 listRec(w, 37 r.Name, 38 r.Description, 39 ) 40 } 41 }