update download app show me
This commit is contained in:
@@ -3,7 +3,15 @@ import { getConfig } from '@/module/get-config.ts';
|
||||
import inquirer from 'inquirer';
|
||||
import { loginInCommand } from '@/module/login/login-by-web.ts';
|
||||
import { queryLogin, storage } from '@/module/query.ts';
|
||||
import chalk from 'chalk';
|
||||
import util from 'util';
|
||||
|
||||
const pick = (obj: any, keys: string[]) => {
|
||||
return keys.reduce((acc, key) => {
|
||||
acc[key] = obj[key];
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
/**
|
||||
* 定义login命令,支持 `-u` 和 `-p` 参数来输入用户名和密码
|
||||
*/
|
||||
@@ -86,13 +94,28 @@ const switchOrgCommand = new Command('switch').argument('<username>', 'Switch to
|
||||
|
||||
program.addCommand(switchOrgCommand);
|
||||
|
||||
const command = new Command('me').description('').action(async () => {
|
||||
try {
|
||||
const res = await showMe(false);
|
||||
console.log('me', res?.data);
|
||||
} catch (error) {
|
||||
console.log('me error', error);
|
||||
}
|
||||
});
|
||||
const command = new Command('me')
|
||||
.option('-a, --all', 'show all info')
|
||||
.description('')
|
||||
.action(async (options) => {
|
||||
try {
|
||||
let res = await showMe(false);
|
||||
if (res.code === 200 && res.data?.accessToken) {
|
||||
res = await showMe(false);
|
||||
}
|
||||
const baseURL = getConfig().baseURL;
|
||||
const pickData = pick(res?.data, ['username', 'type', 'orgs']);
|
||||
|
||||
console.log(chalk.blue('baseURL', baseURL));
|
||||
if (options.all) {
|
||||
console.log(chalk.blue(util.inspect(res?.data, { colors: true, depth: 4 })));
|
||||
} else {
|
||||
// 打印pickData
|
||||
console.log(chalk.blue(util.inspect(pickData, { colors: true, depth: 4 })));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('me error', error);
|
||||
}
|
||||
});
|
||||
|
||||
program.addCommand(command);
|
||||
|
||||
Reference in New Issue
Block a user