detached 688083d

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 VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · 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:
5959 )
6060
6161 // 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)")
6363 rootCmd.PersistentFlags().StringVar(&tokenFlag, "token", "", "Authentication token for remote")
6464 rootCmd.PersistentFlags().BoolVar(&insecureTLSFlag, "insecure", false, "Skip TLS certificate verification for remote HTTPS endpoints")
6565
@@ -172,13 +172,13 @@ Commands are organized by where they run:
172172 // GetRemoteClient returns a remote client if targeting a remote instance,
173173 // or nil if running locally.
174174 func GetRemoteClient() (*remote.Client, bool) {
175- url, token, insecureTLS, _, isRemote := remote.ResolveRemoteFull(remoteFlag, tokenFlag, insecureTLSFlag)
175+ resolved, isRemote := remote.Resolve(remoteFlag, tokenFlag, insecureTLSFlag)
176176 if !isRemote {
177177 return nil, false
178178 }
179179
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...)
182182 return client, true
183183 }
184184
@@ -195,7 +195,7 @@ func remoteClientOptions(token string, insecureTLS bool) []remote.ClientOption {
195195
196196 // IsRemoteMode returns true if CLI is targeting a remote Gordon instance.
197197 func IsRemoteMode() bool {
198- _, _, _, isRemote := remote.ResolveRemote(remoteFlag, tokenFlag, insecureTLSFlag)
198+ _, isRemote := remote.Resolve(remoteFlag, tokenFlag, insecureTLSFlag)
199199 return isRemote
200200 }
201201
@@ -59,7 +59,7 @@ Commands are organized by where they run:
59 )59 )
60 60
61 // Add persistent flags for remote targeting61 // 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, false177 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, true182 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 isRemote199 return isRemote
200 }200 }
201 201

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close