Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit b66b761

Browse files
feat: add cortex version option (#904)
1 parent 777f914 commit b66b761

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

cortex-js/src/infrastructure/commanders/cortex-command.commander.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pkg from '@/../package.json';
12
import { RootCommand, CommandRunner, Option } from 'nest-commander';
23
import { ChatCommand } from './chat.command';
34
import { ModelsCommand } from './models.command';
@@ -18,13 +19,15 @@ import { FileManagerService } from '../services/file-manager/file-manager.servic
1819
import { CortexUsecases } from '@/usecases/cortex/cortex.usecases';
1920
import { ServeStopCommand } from './sub-commands/serve-stop.command';
2021
import ora from 'ora';
22+
import { printSlogan } from '@/utils/logo';
2123
import { EnginesSetCommand } from './engines/engines-set.command';
2224

2325
type ServeOptions = {
2426
address?: string;
2527
port?: number;
2628
logs?: boolean;
2729
dataFolder?: string;
30+
version?: boolean;
2831
};
2932

3033
@RootCommand({
@@ -58,7 +61,15 @@ export class CortexCommand extends CommandRunner {
5861
const host = options?.address || defaultCortexJsHost;
5962
const port = options?.port || defaultCortexJsPort;
6063
const showLogs = options?.logs || false;
64+
const showVersion = options?.version || false;
6165
const dataFolderPath = options?.dataFolder;
66+
if (showVersion) {
67+
printSlogan();
68+
console.log('\n');
69+
console.log(`Cortex CLI - v${pkg.version}`);
70+
console.log(chalk.blue(`Github: ${pkg.homepage}`));
71+
return;
72+
}
6273
return this.startServer(host, port, showLogs, dataFolderPath);
6374
}
6475

@@ -156,4 +167,12 @@ export class CortexCommand extends CommandRunner {
156167
parseDataFolder(value: string) {
157168
return value;
158169
}
170+
171+
@Option({
172+
flags: '-v, --version',
173+
description: 'Show version',
174+
})
175+
parseVersion() {
176+
return true;
177+
}
159178
}

0 commit comments

Comments
 (0)