Skip to content

Commit b77ba3c

Browse files
RyanLee-Devclaude
andcommitted
feat: minimax with no args shows quota or login guide
When invoked with no arguments: - logged in (any credential source) → run quota show - not logged in → print login hint --help still shows the full help text. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5bd8246 commit b77ba3c

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

src/main.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { loadConfig } from './config/loader';
66
import { detectRegion, saveDetectedRegion } from './config/detect-region';
77
import { REGIONS } from './config/schema';
88
import { checkForUpdate, getPendingUpdateNotification } from './update/checker';
9+
import { loadCredentials } from './auth/credentials';
910

1011
const CLI_VERSION = process.env.CLI_VERSION ?? '0.3.1';
1112

@@ -17,15 +18,31 @@ async function main() {
1718
process.exit(0);
1819
}
1920

20-
// Pass 1: find command path from positional args
2121
const commandPath = scanCommandPath(argv);
2222

23-
if (argv.includes('--help') || argv.includes('-h') || commandPath.length === 0) {
23+
if (argv.includes('--help') || argv.includes('-h')) {
2424
registry.printHelp(commandPath, process.stderr);
2525
process.exit(0);
2626
}
2727

28-
// Pass 2: resolve command, then parse flags with the merged schema
28+
// No command: show quota if logged in, else guide to login
29+
if (commandPath.length === 0) {
30+
const { command: quotaCmd } = registry.resolve(['quota', 'show']);
31+
const flags = parseFlags(argv, [...GLOBAL_OPTIONS, ...(quotaCmd.options ?? [])]);
32+
const config = loadConfig(flags);
33+
34+
const hasKey = !!(config.apiKey || config.envApiKey || config.fileApiKey);
35+
const hasOAuth = !!(await loadCredentials());
36+
37+
if (hasKey || hasOAuth) {
38+
await quotaCmd.execute(config, flags);
39+
} else {
40+
process.stderr.write('\n Not logged in.\n\n');
41+
process.stderr.write(' minimax auth login --api-key sk-xxxxx\n\n');
42+
}
43+
process.exit(0);
44+
}
45+
2946
const { command, extra } = registry.resolve(commandPath);
3047
const flags = parseFlags(argv, [...GLOBAL_OPTIONS, ...(command.options ?? [])]);
3148

0 commit comments

Comments
 (0)