feat: login by command by web
This commit is contained in:
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user