Skip to content

Commit a35e74a

Browse files
authored
Merge pull request #15 from MiniMax-AI-Dev/feat/welcome-screen-trim-flags
feat: welcome screen + trim global flags
2 parents b75385f + 6185593 commit a35e74a

6 files changed

Lines changed: 25 additions & 105 deletions

File tree

README.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -128,55 +128,6 @@ minimax update latest
128128

129129
---
130130

131-
## Global Flags
132-
133-
| Flag | Description |
134-
|---|---|
135-
| `--api-key <key>` | API key (overrides config) |
136-
| `--region <global\|cn>` | API region |
137-
| `--output <text\|json\|yaml>` | Output format |
138-
| `--quiet` | Data only on stdout, no decorations |
139-
| `--verbose` | Print HTTP request/response |
140-
| `--dry-run` | Show request body, no API call |
141-
| `--async` | Return task ID immediately (video) |
142-
| `--non-interactive` | Disable prompts (CI/agent mode) |
143-
| `--timeout <seconds>` | Request timeout (default: 300) |
144-
| `--no-color` | Disable ANSI colors |
145-
146-
Add `--help` to any command for full options.
147-
148-
---
149-
150-
## Agent / CI Integration
151-
152-
Export all commands as JSON Tool Schema in one shot:
153-
154-
```bash
155-
minimax config export-schema | jq .
156-
minimax config export-schema --command "text chat"
157-
```
158-
159-
Compatible with Cursor, Cline, Dify, and any framework that speaks Anthropic/OpenAI tool schemas. See [skill/SKILL.md](skill/SKILL.md) for the full integration guide.
160-
161-
**Piping:**
162-
163-
```bash
164-
minimax text chat --message "Hello" --output json | jq .content
165-
minimax image "A logo" --quiet | xargs curl -O
166-
minimax video generate --prompt "A robot" --async --quiet
167-
```
168-
169-
stdout is always clean data. stderr carries all UI (status bar, spinners, progress).
170-
171-
---
172-
173-
## Output Philosophy
174-
175-
- `stdout` → data only (text, URLs, JSON, raw audio bytes)
176-
- `stderr` → status bar, progress, warnings, help
177-
178-
---
179-
180131
## License
181132

182133
MIT

README_CN.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -128,55 +128,6 @@ minimax update latest
128128

129129
---
130130

131-
## 全局 Flag
132-
133-
| Flag | 说明 |
134-
|---|---|
135-
| `--api-key <key>` | API Key(覆盖配置文件) |
136-
| `--region <global\|cn>` | 接口区域 |
137-
| `--output <text\|json\|yaml>` | 输出格式 |
138-
| `--quiet` | 只输出数据,无装饰信息 |
139-
| `--verbose` | 打印 HTTP 请求/响应详情 |
140-
| `--dry-run` | 展示请求体,不发起 API 调用 |
141-
| `--async` | 立即返回任务 ID(视频异步模式) |
142-
| `--non-interactive` | 禁用交互提示(CI/Agent 模式) |
143-
| `--timeout <秒>` | 请求超时(默认 300 秒) |
144-
| `--no-color` | 关闭 ANSI 颜色 |
145-
146-
任意命令后加 `--help` 查看完整参数。
147-
148-
---
149-
150-
## Agent / CI 集成
151-
152-
一键导出所有命令的 JSON Tool Schema:
153-
154-
```bash
155-
minimax config export-schema | jq .
156-
minimax config export-schema --command "text chat"
157-
```
158-
159-
兼容 Cursor、Cline、Dify 等任何支持 Anthropic/OpenAI Tool Schema 的 Agent 框架。完整集成指南见 [skill/SKILL.md](skill/SKILL.md)
160-
161-
**管道用法:**
162-
163-
```bash
164-
minimax text chat --message "你好" --output json | jq .content
165-
minimax image "Logo" --quiet | xargs curl -O
166-
minimax video generate --prompt "机器人" --async --quiet
167-
```
168-
169-
stdout 始终是纯净数据,stderr 承载所有 UI(状态栏、进度、警告)。
170-
171-
---
172-
173-
## 输出规范
174-
175-
- `stdout` → 纯数据(文字、URL、JSON、原始音频字节流)
176-
- `stderr` → 状态栏、进度条、警告、帮助信息
177-
178-
---
179-
180131
## 许可证
181132

182133
MIT

src/command.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ export const GLOBAL_OPTIONS: OptionDef[] = [
4747
{ flag: '--quiet', description: 'Suppress non-essential output' },
4848
{ flag: '--verbose', description: 'Print HTTP request/response details' },
4949
{ flag: '--no-color', description: 'Disable ANSI colors' },
50-
{ flag: '--yes', description: 'Skip confirmation prompts' },
5150
{ flag: '--dry-run', description: 'Dry run mode' },
5251
{ flag: '--non-interactive', description: 'Disable interactive prompts' },
53-
{ flag: '--async', description: 'Return task ID immediately' },
5452
{ flag: '--help', description: 'Show help' },
5553
{ flag: '--version', description: 'Print version' },
5654
];

src/commands/auth/logout.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export default defineCommand({
88
name: 'auth logout',
99
description: 'Revoke tokens and clear stored credentials',
1010
usage: 'minimax auth logout [--yes] [--dry-run]',
11+
options: [
12+
{ flag: '--yes', description: 'Skip confirmation prompt' },
13+
],
1114
examples: [
1215
'minimax auth logout',
1316
'minimax auth logout --dry-run',

src/main.ts

Lines changed: 22 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,33 @@ 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: help + quota (if logged in) or login guide
29+
if (commandPath.length === 0) {
30+
registry.printHelp([], process.stderr);
31+
32+
const { command: quotaCmd } = registry.resolve(['quota', 'show']);
33+
const flags = parseFlags(argv, [...GLOBAL_OPTIONS, ...(quotaCmd.options ?? [])]);
34+
const config = loadConfig(flags);
35+
36+
const hasKey = !!(config.apiKey || config.envApiKey || config.fileApiKey);
37+
const hasOAuth = !!(await loadCredentials());
38+
39+
if (hasKey || hasOAuth) {
40+
await quotaCmd.execute(config, flags);
41+
} else {
42+
process.stderr.write(' Not logged in.\n');
43+
process.stderr.write(' minimax auth login --api-key sk-xxxxx\n\n');
44+
}
45+
process.exit(0);
46+
}
47+
2948
const { command, extra } = registry.resolve(commandPath);
3049
const flags = parseFlags(argv, [...GLOBAL_OPTIONS, ...(command.options ?? [])]);
3150

src/registry.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ Global Flags:
165165
--verbose Print HTTP request/response details
166166
--timeout <seconds> Request timeout (default: 300)
167167
--no-color Disable ANSI colors and spinners
168-
--yes Skip confirmation prompts
169168
--dry-run Show what would happen without executing
170169
--non-interactive Disable interactive prompts (CI/agent mode)
171-
--async Return task ID immediately without polling
172170
--version Print version and exit
173171
--help Show help
174172

0 commit comments

Comments
 (0)