2093 extensibility add twenty auth switch command (#17286)
add auth:switch and auth:list commands
This commit is contained in:
@@ -17,15 +17,21 @@ program
|
||||
|
||||
program.option(
|
||||
'--workspace <name>',
|
||||
'Use a specific workspace configuration',
|
||||
'default',
|
||||
'Use a specific workspace configuration (overrides the default set by auth:switch)',
|
||||
);
|
||||
|
||||
program.hook('preAction', (thisCommand) => {
|
||||
program.hook('preAction', async (thisCommand) => {
|
||||
const opts = (thisCommand as any).optsWithGlobals
|
||||
? (thisCommand as any).optsWithGlobals()
|
||||
: thisCommand.opts();
|
||||
const workspace = opts.workspace;
|
||||
|
||||
// If --workspace is provided, use it; otherwise, read the persisted default
|
||||
let workspace = opts.workspace;
|
||||
if (!workspace) {
|
||||
const configService = new ConfigService();
|
||||
workspace = await configService.getDefaultWorkspace();
|
||||
}
|
||||
|
||||
ConfigService.setActiveWorkspace(workspace);
|
||||
console.log(
|
||||
chalk.gray(`👩💻 Workspace - ${ConfigService.getActiveWorkspace()}`),
|
||||
|
||||
Reference in New Issue
Block a user