30
Options.withDescription('Skip auto-opening the browser')
31
);
32
33
+const noWait = Options.boolean('no-wait').pipe(
34
+ Options.withDefault(false),
35
+ Options.withDescription('Do not wait for authorization; only print link info')
36
+);
37
+
38
/**
39
* Open the browser and poll until the connected account becomes ACTIVE.
40
* On success, outputs valid JSON to stdout for piping (e.g. to jq).
137
*/
138
export const connectedAccountsCmd$Link = Command.make(
139
'link',
135
- { toolkit, authConfig, userId, noBrowser },
136
- ({ toolkit, authConfig, userId, noBrowser }) =>
140
+ { toolkit, authConfig, userId, noBrowser, noWait },
141
+ ({ toolkit, authConfig, userId, noBrowser, noWait }) =>
142
Effect.gen(function* () {
143
if (!(yield* requireAuth)) return;
144
209
return;
210
}
211
207
- yield* waitForActiveConnection(
208
- ui,
209
- repo,
210
- linkOpt.value.connected_account_id,
211
- linkOpt.value.redirect_url,
212
- noBrowser
213
- );
212
+ const { connected_account_id: connId, redirect_url: redirectUrl } = linkOpt.value;
213
+
214
+ if (noWait) {
215
+ yield* ui.note(redirectUrl, 'Redirect URL');
216
+ yield* ui.output(
217
+ JSON.stringify(
218
+ {
219
+ status: 'pending',
220
+ message: 'Complete authorization by opening the URL',
221
+ connected_account_id: connId,
222
+ redirect_url: redirectUrl,
223
+ },
224
+ null,
225
+ 2
226
+ )
227
+ );
228
+ } else {
229
+ yield* waitForActiveConnection(ui, repo, connId, redirectUrl, noBrowser);
230
+ }
231
} else {
232
// Path B: Tool Router flow — toolkit is guaranteed Some (validated above)
233
const toolkitSlug = Option.getOrThrow(toolkit);
271
return;
272
}
273
257
- yield* waitForActiveConnection(ui, repo, connAccountId, redirectUrl, noBrowser);
274
+ if (noWait) {
275
+ yield* ui.note(redirectUrl, 'Redirect URL');
276
+ yield* ui.output(
277
+ JSON.stringify(
278
+ {
279
+ status: 'pending',
280
+ message: 'Complete authorization by opening the URL',
281
+ connected_account_id: connAccountId,
282
+ redirect_url: redirectUrl,
283
+ toolkit: toolkitSlug,
284
+ },
285
+ null,
286
+ 2
287
+ )
288
+ );
289
+ } else {
290
+ yield* waitForActiveConnection(ui, repo, connAccountId, redirectUrl, noBrowser);
291
+ }
292
}
293
})
294
).pipe(Command.withDescription('Link an external account via OAuth redirect.'));