feat: login by command by web

This commit is contained in:
2025-02-25 20:04:24 +08:00
parent 02a1f51d63
commit 26c6248d10
8 changed files with 644 additions and 210 deletions

View File

@@ -1,19 +1,24 @@
import { program, Command } from '@/program.ts';
import { getConfig, writeConfig } from '@/module/get-config.ts';
import { getBaseURL } from '@/module/query.ts';
import { queryLogin, queryMe, switchOrg, switchMe } from '@/query/index.ts';
import inquirer from 'inquirer';
import { runApp } from '../app-run.ts';
// 导入 login 命令
import { chalk } from '@/module/chalk.ts';
import { loginInCommand } from '@/module/login/login-by-web.ts';
// 定义login命令支持 `-u` 和 `-p` 参数来输入用户名和密码
const loginCommand = new Command('login')
.description('Login to the application')
.option('-u, --username <username>', 'Specify username')
.option('-p, --password <password>', 'Specify password')
.option('-w, --web', 'Login on the web')
.action(async (options) => {
const config = getConfig();
let { username, password } = options;
if (options.web) {
await loginInCommand();
return;
}
// 如果没有传递参数,则通过交互式输入
if (!username || !password) {
const answers = await inquirer.prompt([