refactor(cli): wire Resolve() into GetRemoteClient, add -r flag
GetRemoteClient and IsRemoteMode now use remote.Resolve(). --remote/-r accepts saved names or ad-hoc URLs.
- commit
- 688083d8d9bdb01487c7ab6762d9d5fe465b5f00
- author
- brice · · 2026-04-04 11:25 UTC
- parent
- c1925b1
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +5 -5
M internal/adapters/in/cli/root.go +5 -5
| @@ -59,7 +59,7 @@ Commands are organized by where they run: | |||
| 59 | 59 | ) | |
| 60 | 60 | ||
| 61 | 61 | // Add persistent flags for remote targeting | |
| 62 | - | rootCmd.PersistentFlags().StringVar(&remoteFlag, "remote", "", "Remote Gordon URL (e.g., https://gordon.mydomain.com)") | |
| 62 | + | rootCmd.PersistentFlags().StringVarP(&remoteFlag, "remote", "r", "", "Remote name or URL (e.g., prod, https://gordon.mydomain.com)") | |
| 63 | 63 | rootCmd.PersistentFlags().StringVar(&tokenFlag, "token", "", "Authentication token for remote") | |
| 64 | 64 | rootCmd.PersistentFlags().BoolVar(&insecureTLSFlag, "insecure", false, "Skip TLS certificate verification for remote HTTPS endpoints") | |
| 65 | 65 | ||
| @@ -172,13 +172,13 @@ Commands are organized by where they run: | |||
| 172 | 172 | // GetRemoteClient returns a remote client if targeting a remote instance, | |
| 173 | 173 | // or nil if running locally. | |
| 174 | 174 | func GetRemoteClient() (*remote.Client, bool) { | |
| 175 | - | url, token, insecureTLS, _, isRemote := remote.ResolveRemoteFull(remoteFlag, tokenFlag, insecureTLSFlag) | |
| 175 | + | resolved, isRemote := remote.Resolve(remoteFlag, tokenFlag, insecureTLSFlag) | |
| 176 | 176 | if !isRemote { | |
| 177 | 177 | return nil, false | |
| 178 | 178 | } | |
| 179 | 179 | ||
| 180 | - | opts := remoteClientOptions(token, insecureTLS) | |
| 181 | - | client := remote.NewClient(url, opts...) | |
| 180 | + | opts := remoteClientOptions(resolved.Token, resolved.InsecureTLS) | |
| 181 | + | client := remote.NewClient(resolved.URL, opts...) | |
| 182 | 182 | return client, true | |
| 183 | 183 | } | |
| 184 | 184 | ||
| @@ -195,7 +195,7 @@ func remoteClientOptions(token string, insecureTLS bool) []remote.ClientOption { | |||
| 195 | 195 | ||
| 196 | 196 | // IsRemoteMode returns true if CLI is targeting a remote Gordon instance. | |
| 197 | 197 | func IsRemoteMode() bool { | |
| 198 | - | _, _, _, isRemote := remote.ResolveRemote(remoteFlag, tokenFlag, insecureTLSFlag) | |
| 198 | + | _, isRemote := remote.Resolve(remoteFlag, tokenFlag, insecureTLSFlag) | |
| 199 | 199 | return isRemote | |
| 200 | 200 | } | |
| 201 | 201 | ||
| @@ -59,7 +59,7 @@ Commands are organized by where they run: | |||||
| 59 | ) | 59 | ) | ||
| 60 | 60 | ||||
| 61 | // Add persistent flags for remote targeting | 61 | // Add persistent flags for remote targeting | ||
| 62 | - | rootCmd.PersistentFlags().StringVar(&remoteFlag, "remote", "", "Remote Gordon URL (e.g., https://gordon.mydomain.com)") | 62 | + | rootCmd.PersistentFlags().StringVarP(&remoteFlag, "remote", "r", "", "Remote name or URL (e.g., prod, https://gordon.mydomain.com)") |
| 63 | rootCmd.PersistentFlags().StringVar(&tokenFlag, "token", "", "Authentication token for remote") | 63 | rootCmd.PersistentFlags().StringVar(&tokenFlag, "token", "", "Authentication token for remote") | ||
| 64 | rootCmd.PersistentFlags().BoolVar(&insecureTLSFlag, "insecure", false, "Skip TLS certificate verification for remote HTTPS endpoints") | 64 | rootCmd.PersistentFlags().BoolVar(&insecureTLSFlag, "insecure", false, "Skip TLS certificate verification for remote HTTPS endpoints") | ||
| 65 | 65 | ||||
| @@ -172,13 +172,13 @@ Commands are organized by where they run: | |||||
| 172 | // GetRemoteClient returns a remote client if targeting a remote instance, | 172 | // GetRemoteClient returns a remote client if targeting a remote instance, | ||
| 173 | // or nil if running locally. | 173 | // or nil if running locally. | ||
| 174 | func GetRemoteClient() (*remote.Client, bool) { | 174 | func GetRemoteClient() (*remote.Client, bool) { | ||
| 175 | - | url, token, insecureTLS, _, isRemote := remote.ResolveRemoteFull(remoteFlag, tokenFlag, insecureTLSFlag) | 175 | + | resolved, isRemote := remote.Resolve(remoteFlag, tokenFlag, insecureTLSFlag) |
| 176 | if !isRemote { | 176 | if !isRemote { | ||
| 177 | return nil, false | 177 | return nil, false | ||
| 178 | } | 178 | } | ||
| 179 | 179 | ||||
| 180 | - | opts := remoteClientOptions(token, insecureTLS) | 180 | + | opts := remoteClientOptions(resolved.Token, resolved.InsecureTLS) |
| 181 | - | client := remote.NewClient(url, opts...) | 181 | + | client := remote.NewClient(resolved.URL, opts...) |
| 182 | return client, true | 182 | return client, true | ||
| 183 | } | 183 | } | ||
| 184 | 184 | ||||
| @@ -195,7 +195,7 @@ func remoteClientOptions(token string, insecureTLS bool) []remote.ClientOption { | |||||
| 195 | 195 | ||||
| 196 | // IsRemoteMode returns true if CLI is targeting a remote Gordon instance. | 196 | // IsRemoteMode returns true if CLI is targeting a remote Gordon instance. | ||
| 197 | func IsRemoteMode() bool { | 197 | func IsRemoteMode() bool { | ||
| 198 | - | _, _, _, isRemote := remote.ResolveRemote(remoteFlag, tokenFlag, insecureTLSFlag) | 198 | + | _, isRemote := remote.Resolve(remoteFlag, tokenFlag, insecureTLSFlag) |
| 199 | return isRemote | 199 | return isRemote | ||
| 200 | } | 200 | } | ||
| 201 | 201 | ||||