@@ -15,13 +15,14 @@ import (
1515 "github.com/awslabs/aws-sdk-go/aws"
1616 "github.com/awslabs/aws-sdk-go/service/ec2"
1717 "github.com/codegangsta/cli"
18+ "github.com/olekukonko/tablewriter"
1819)
1920
2021// Name is the exported name of this application.
2122const Name = "aws-ssh"
2223
2324// Version is the current version of this application.
24- const Version = "0.0.2 .dev"
25+ const Version = "0.0.3 .dev"
2526
2627func main () {
2728 app := cli .NewApp ()
@@ -157,10 +158,8 @@ func selectInstance(server string, instances []Instance) (Instance, error) {
157158 return matches [0 ], nil
158159 }
159160 fmt .Println ("Found " , len (matches ), "matches in" , len (instances ), "instances" )
160- for pos , match := range matches {
161- fmt .Println (pos , " " , match .Name )
162- }
163- fmt .Print ("Select vm: " )
161+ writeInstances (matches )
162+ fmt .Print ("Select vm Num : " )
164163 var input string
165164 fmt .Scanln (& input )
166165 fmt .Print (input )
@@ -172,6 +171,17 @@ func selectInstance(server string, instances []Instance) (Instance, error) {
172171
173172}
174173
174+ func writeInstances (matches []Instance ){
175+ table := tablewriter .NewWriter (os .Stdout )
176+ table .SetHeader ([]string {"Num" , "Name" , "State" , "IP" })
177+
178+ for pos , match := range matches {
179+ table .Append ([]string { strconv .Itoa (pos ), match .Name , match .State , match .Host })
180+ // fmt.Println(pos, " ", match.Name, " ", match.State, " ", match.Host)
181+ }
182+ table .Render ()
183+ }
184+
175185func shell (inst Instance ) {
176186 remoteServer := inst .Host
177187 if inst .User != "" {
0 commit comments