fix: remove switchMe and switchOrg only use switch
This commit is contained in:
parent
f42e1c8f24
commit
02a1f51d63
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/envision-cli",
|
||||
"version": "0.0.21",
|
||||
"version": "0.0.22",
|
||||
"description": "envision command tools",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
|
@ -73,8 +73,7 @@ const showMe = async (show = true) => {
|
||||
return me;
|
||||
};
|
||||
|
||||
const switchOrgCommand = new Command('switchOrg').argument('<username>', 'Switch to another organization').action(async (options) => {
|
||||
// console.log('options', options);
|
||||
const switchOrgCommand = new Command('switch').argument('<username>', 'Switch to another organization or username').action(async (username) => {
|
||||
const config = getConfig();
|
||||
if (!config.token) {
|
||||
console.log('Please login first');
|
||||
@ -86,42 +85,24 @@ const switchOrgCommand = new Command('switchOrg').argument('<username>', 'Switch
|
||||
return;
|
||||
}
|
||||
const me = meGet.data?.value || {};
|
||||
if (me?.username === options) {
|
||||
if (me?.username === username) {
|
||||
// console.log('Already in', options);
|
||||
console.log('success switch to', options);
|
||||
console.log('success switch to', username);
|
||||
return;
|
||||
}
|
||||
const res = await switchOrg(options);
|
||||
const res = await switchOrg(username);
|
||||
if (res.code === 200) {
|
||||
const token = res.data.token;
|
||||
writeConfig({ ...config, token });
|
||||
console.log('Switch Org Success');
|
||||
console.log(`Switch ${username} Success`);
|
||||
await showMe();
|
||||
} else {
|
||||
console.log('Switch Org Failed', res.message || '');
|
||||
console.log(`Switch ${username} Failed`, res.message || '');
|
||||
}
|
||||
});
|
||||
|
||||
program.addCommand(switchOrgCommand);
|
||||
|
||||
const switchMeCommand = new Command('switchMe').action(async () => {
|
||||
const config = getConfig();
|
||||
if (!config.token) {
|
||||
console.log('Please login first');
|
||||
return;
|
||||
}
|
||||
const res = await switchMe();
|
||||
if (res.code === 200) {
|
||||
const token = res.data.token;
|
||||
writeConfig({ ...config, token });
|
||||
console.log('Switch Me Success');
|
||||
showMe();
|
||||
} else {
|
||||
console.log('Switch Me Failed', res.message || '');
|
||||
}
|
||||
});
|
||||
program.addCommand(switchMeCommand);
|
||||
|
||||
const command = new Command('me').description('').action(async () => {
|
||||
await showMe();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user