Add profile to twenty-cli authentication (#15778)

As title
Eg: 
<img width="641" height="45" alt="image"
src="https://github.com/user-attachments/assets/0ac159db-ebcf-4c21-af1b-b089ee3b39f8"
/>

Not breaking
This commit is contained in:
martmull
2025-11-13 15:08:53 +01:00
committed by GitHub
parent 0cab2b49fc
commit ab967bf81f
7 changed files with 100 additions and 176 deletions
+15 -5
View File
@@ -6,7 +6,7 @@ import { readFileSync } from 'fs';
import { join } from 'path';
import { AppCommand } from './commands/app.command';
import { AuthCommand } from './commands/auth.command';
import { ConfigCommand } from './commands/config.command';
import { ConfigService } from './services/config.service';
const packageJson = JSON.parse(
readFileSync(join(__dirname, '../package.json'), 'utf-8'),
@@ -20,14 +20,24 @@ program
.version(packageJson.version);
program.option(
'--api-url <url>',
'Twenty API URL',
process.env.TWENTY_API_URL || 'http://localhost:3000',
'--workspace <name>',
'Use a specific workspace configuration',
'default',
);
program.hook('preAction', (thisCommand) => {
const opts = (thisCommand as any).optsWithGlobals
? (thisCommand as any).optsWithGlobals()
: thisCommand.opts();
const workspace = opts.workspace;
ConfigService.setActiveWorkspace(workspace);
console.log(
chalk.gray(`👩‍💻 Workspace - ${ConfigService.getActiveWorkspace()}`),
);
});
program.addCommand(new AuthCommand().getCommand());
program.addCommand(new AppCommand().getCommand());
program.addCommand(new ConfigCommand().getCommand());
program.exitOverride();