@@ -41,28 +41,14 @@ struct SSHListCommand: ParsableCommand {
4141
4242 print ( " Available SSH hosts: " )
4343 for (index, entry) in entries. enumerated ( ) {
44- let hostName = entry. host ?? " unnamed "
44+ let hostName = entry. host
4545 let number = index + 1
4646
4747 if detail {
4848 print ( " \( number) . \( hostName) " )
49- if let user = entry. user {
50- print ( " User: \( user) " )
51- }
52- if let hostname = entry. hostname {
53- print ( " Hostname: \( hostname) " )
54- }
55- if let port = entry. port {
56- print ( " Port: \( port) " )
57- }
58- if let identityFile = entry. identityFile {
59- print ( " IdentityFile: \( identityFile) " )
60- }
61- if let forwardAgent = entry. forwardAgent {
62- print ( " ForwardAgent: \( forwardAgent) " )
63- }
64- if let proxyCommand = entry. proxyCommand {
65- print ( " ProxyCommand: \( proxyCommand) " )
49+ // Display all directives for this host
50+ for directive in entry. directives {
51+ print ( " \( directive. key) : \( directive. value) " )
6652 }
6753 print ( " " )
6854 } else {
@@ -113,47 +99,11 @@ struct SSHShowCommand: ParsableCommand {
11399 entry = foundEntry
114100 }
115101
116- print ( " Host: \( entry. host ?? " unnamed " ) " )
117-
118- if let hostname = entry. hostname {
119- print ( " Hostname: \( hostname) " )
120- }
121- if let user = entry. user {
122- print ( " User: \( user) " )
123- }
124- if let port = entry. port {
125- print ( " Port: \( port) " )
126- }
127- if let identityFile = entry. identityFile {
128- print ( " IdentityFile: \( identityFile) " )
129- }
130- if let forwardAgent = entry. forwardAgent {
131- print ( " ForwardAgent: \( forwardAgent) " )
132- }
133- if let proxyCommand = entry. proxyCommand {
134- print ( " ProxyCommand: \( proxyCommand) " )
135- }
136- if let serverAliveInterval = entry. serverAliveInterval {
137- print ( " ServerAliveInterval: \( serverAliveInterval) " )
138- }
139- if let serverAliveCountMax = entry. serverAliveCountMax {
140- print ( " ServerAliveCountMax: \( serverAliveCountMax) " )
141- }
142- if let strictHostKeyChecking = entry. strictHostKeyChecking {
143- print ( " StrictHostKeyChecking: \( strictHostKeyChecking) " )
144- }
145- if let userKnownHostsFile = entry. userKnownHostsFile {
146- print ( " UserKnownHostsFile: \( userKnownHostsFile) " )
147- }
148- if let connectTimeout = entry. connectTimeout {
149- print ( " ConnectTimeout: \( connectTimeout) " )
150- }
102+ print ( " Host: \( entry. host) " )
151103
152- if !entry. otherOptions. isEmpty {
153- print ( " Other Options: " )
154- for (key, value) in entry. otherOptions {
155- print ( " \( key) : \( value) " )
156- }
104+ // Iterate through all directives and print them
105+ for directive in entry. directives {
106+ print ( " \( directive. key) : \( directive. value) " )
157107 }
158108 } catch {
159109 print ( " Error: \( error. localizedDescription) " )
@@ -188,7 +138,7 @@ struct SSHConnectCommand: ParsableCommand {
188138 // Check if input is a number
189139 if let index = Int ( host) , index > 0 , index <= entries. count {
190140 hostEntry = entries [ index - 1 ]
191- hostDisplayName = " \( index) . \( hostEntry. host ?? " unnamed " ) "
141+ hostDisplayName = " \( index) . \( hostEntry. host) "
192142 } else {
193143 // Search by host name
194144 guard let foundEntry = entries. first ( where: { $0. host == host } ) else {
@@ -197,7 +147,7 @@ struct SSHConnectCommand: ParsableCommand {
197147 throw ExitCode . failure
198148 }
199149 hostEntry = foundEntry
200- hostDisplayName = hostEntry. host ?? " unnamed "
150+ hostDisplayName = hostEntry. host
201151 }
202152
203153 if isDebugMode {
@@ -229,7 +179,7 @@ struct SSHConnectCommand: ParsableCommand {
229179 if let username = hostEntry. user, let hostname = hostEntry. hostname {
230180 targetAddress = " \( username) @ \( hostname) "
231181 } else {
232- targetAddress = hostEntry. host ?? host
182+ targetAddress = hostEntry. host // Updated since host is now non-optional
233183 }
234184 argsArray. append ( targetAddress)
235185
@@ -257,7 +207,7 @@ struct SSHConnectCommand: ParsableCommand {
257207 print ( " System version: \( ProcessInfo . processInfo. operatingSystemVersionString) " )
258208
259209 print ( " \n ===== Host Configuration Information ===== " )
260- print ( " Host: \( hostEntry. host ?? " unnamed " ) " )
210+ print ( " Host: \( hostEntry. host) " )
261211 print ( " Hostname: \( hostEntry. hostname ?? " not specified " ) " )
262212 print ( " User: \( hostEntry. user ?? " not specified " ) " )
263213 print ( " Port: \( hostEntry. port ?? " not specified (default: 22) " ) " )
0 commit comments