@@ -61,7 +61,7 @@ func (l *list) Run(tty io.ReadWriter, args ...string) error {
61
61
sc := value .(ssh.Conn )
62
62
id := fmt .Sprintf ("%s" , idStr )
63
63
64
- if filter == "" || flags [ 'a' ] {
64
+ if filter == "" {
65
65
toReturn = append (toReturn , displayItem {id : id , sc : sc })
66
66
return true
67
67
}
@@ -92,31 +92,40 @@ func (l *list) Run(tty io.ReadWriter, args ...string) error {
92
92
return nil
93
93
}
94
94
95
- sep := " "
95
+ sep := ", "
96
96
if flags ['l' ] {
97
97
sep = "\n "
98
98
}
99
99
100
- for _ , tr := range toReturn {
100
+ for i , tr := range toReturn {
101
101
102
102
if ! flags ['n' ] && ! flags ['i' ] && ! flags ['a' ] {
103
- fmt .Fprintf (tty , "%s%s" , tr .id , sep )
103
+ fmt .Fprint (tty , tr .id )
104
+ if i != len (toReturn ) {
105
+ fmt .Fprint (tty , sep )
106
+ }
104
107
continue
105
108
}
106
109
107
110
if flags ['a' ] {
108
- fmt .Fprintf (tty , "%s" , tr .id )
111
+ fmt .Fprint (tty , tr .id )
109
112
}
110
113
111
114
if flags ['n' ] || flags ['a' ] {
112
- fmt .Fprintf (tty , " %s" , tr .sc .User ())
115
+ fmt .Fprint (tty , " " + tr .sc .User ())
113
116
}
114
117
115
118
if flags ['i' ] || flags ['a' ] {
116
- fmt .Fprintf (tty , " %s" , tr .sc .RemoteAddr ().String ())
119
+ fmt .Fprint (tty , " " + tr .sc .RemoteAddr ().String ())
120
+ }
121
+
122
+ if i != len (toReturn ) {
123
+ fmt .Fprint (tty , sep )
117
124
}
125
+ }
118
126
119
- fmt .Fprintf (tty , "%s" , sep )
127
+ if ! flags ['l' ] {
128
+ fmt .Fprint (tty , "\n " )
120
129
}
121
130
122
131
return nil
@@ -129,7 +138,7 @@ func (l *list) Help(explain bool) string {
129
138
return makeHelpText (
130
139
"ls [OPTION] [FILTER]" ,
131
140
"Filter uses glob matching against all attributes of a target (hostname, ip, id)" ,
132
- "\t -a\t Show all attributes of all hosts " ,
141
+ "\t -a\t Show all attributes" ,
133
142
"\t -n\t Show only hostnames" ,
134
143
"\t -i\t Show only IP" ,
135
144
"\t -t\t Print all attributes in pretty table" ,
0 commit comments