fix: add login -e 登录通过env的环境变量登录
This commit is contained in:
@@ -21,12 +21,29 @@ const loginCommand = new Command('login')
|
||||
.option('-p, --password <password>', 'Specify password')
|
||||
.option('-f, --force', 'Force login')
|
||||
.option('-w, --web', 'Login on the web')
|
||||
.option('-e, --env', 'Login from KEVISUAL_TOKEN environment variable')
|
||||
|
||||
.action(async (options) => {
|
||||
let { username, password } = options;
|
||||
if (options.web) {
|
||||
await loginInCommand();
|
||||
return;
|
||||
}
|
||||
// 从环境变量登录
|
||||
if (options.env) {
|
||||
const envToken = getEnvToken();
|
||||
if (!envToken) {
|
||||
console.log('环境变量 KEVISUAL_TOKEN 未设置');
|
||||
return;
|
||||
}
|
||||
const res = await showMe(false);
|
||||
if (res.code === 200) {
|
||||
console.log('Login success:', res.data?.username || res.data?.email);
|
||||
} else {
|
||||
console.log('Login failed:', res.message || 'Invalid token');
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 如果没有传递参数,则通过交互式输入
|
||||
if (!username) {
|
||||
username = await input({
|
||||
|
||||
Reference in New Issue
Block a user