fix: apply provider flag before startup banner (#322)

This commit is contained in:
Vasanth T
2026-04-04 11:49:02 +05:30
committed by GitHub
parent bd4daa3ee7
commit cdbe016e6f
3 changed files with 50 additions and 17 deletions

View File

@@ -134,6 +134,18 @@ async function main(): Promise<void> {
return;
}
// --provider: set provider env vars early so saved-profile resolution,
// validation, and the startup banner all see the intended provider/model.
if (args.includes('--provider')) {
const { applyProviderFlagFromArgs } = await import('../utils/providerFlag.js');
const result = applyProviderFlagFromArgs(args);
if (result?.error) {
// biome-ignore lint/suspicious/noConsole:: intentional error output
console.error(`Error: ${result.error}`);
process.exit(1);
}
}
{
const { enableConfigs } = await import('../utils/config.js')
enableConfigs()
@@ -406,22 +418,6 @@ async function main(): Promise<void> {
process.env.CLAUDE_CODE_SIMPLE = '1';
}
// --provider: set provider env vars early, before main module loads.
// This mirrors the --bare pattern: env vars must be in place before
// Commander option building and module-level constants are evaluated.
if (args.includes('--provider')) {
const { parseProviderFlag, applyProviderFlag } = await import('../utils/providerFlag.js');
const provider = parseProviderFlag(args);
if (provider) {
const result = applyProviderFlag(provider, args);
if (result.error) {
// biome-ignore lint/suspicious/noConsole:: intentional error output
console.error(`Error: ${result.error}`);
process.exit(1);
}
}
}
// No special flags detected, load and run the full CLI
if (process.env.OPENCLAUDE_DISABLE_EARLY_INPUT !== '1') {
const {