-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cli): default --wait in non-interactive mode, slim init --help #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/organisations-list
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,8 +69,9 @@ authenticated, this completes in seconds.` | |
| helpValue: '<name>', | ||
| }), | ||
| wait: Flags.boolean({ | ||
| default: false, | ||
| description: 'Block until login completes (up to 5 minutes). Recommended for agents and CI.', | ||
| allowNo: true, | ||
| description: | ||
| 'Block until login completes (up to 5 minutes). Defaults to true in non-interactive contexts (CI, agents); pass `--no-wait` to opt out.', | ||
| }), | ||
| 'with-token': Flags.boolean({ | ||
| description: 'Read token from standard input', | ||
|
|
@@ -82,6 +83,12 @@ authenticated, this completes in seconds.` | |
| const {flags} = await this.parse(LoginCommand) | ||
| const {'sso-provider': ssoProvider, 'with-token': withToken, ...loginFlags} = flags | ||
|
|
||
| // Default `--wait` to true when not interactive and not using --with-token, | ||
| // so agents and CI get a deterministic exit code without having to discover | ||
| // the flag. Pass `--no-wait` to opt out. | ||
| const effectiveWait = | ||
| typeof flags.wait === 'boolean' ? flags.wait : !isInteractive() && !withToken | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In non-interactive Useful? React with 👍 / 👎. |
||
|
|
||
| try { | ||
| const token = withToken ? await readTokenFromStdin() : undefined | ||
|
|
||
|
|
@@ -91,9 +98,10 @@ authenticated, this completes in seconds.` | |
| ssoProvider, | ||
| telemetry: this.telemetry, | ||
| token, | ||
| wait: effectiveWait, | ||
| }) | ||
|
|
||
| if (isInteractive() || token || flags.wait) { | ||
| if (isInteractive() || token || effectiveWait) { | ||
| this.log('Login successful') | ||
| } | ||
| } catch (error) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When non-interactive
sanity loginis run without--wait/--no-waitand the config already contains an invalid or expiredauthToken, this new default enters the wait loop afterlogin()has already calledgetCliToken(), seeding the parent process token cache with the stale token. The background child writes the new token in a separate process, so it cannot clear the parent's cache; subsequentvalidateSession()calls keep checking the old token and the command times out after 5 minutes even though OAuth completed. Clear the CLI token cache or read the config fresh before/during the wait loop.Useful? React with 👍 / 👎.