Skip to content

Commit

Permalink
feat: add cortex version option (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
marknguyen1302 authored Jul 24, 2024
1 parent 777f914 commit b66b761
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pkg from '@/../package.json';
import { RootCommand, CommandRunner, Option } from 'nest-commander';
import { ChatCommand } from './chat.command';
import { ModelsCommand } from './models.command';
Expand All @@ -18,13 +19,15 @@ import { FileManagerService } from '../services/file-manager/file-manager.servic
import { CortexUsecases } from '@/usecases/cortex/cortex.usecases';
import { ServeStopCommand } from './sub-commands/serve-stop.command';
import ora from 'ora';
import { printSlogan } from '@/utils/logo';
import { EnginesSetCommand } from './engines/engines-set.command';

type ServeOptions = {
address?: string;
port?: number;
logs?: boolean;
dataFolder?: string;
version?: boolean;
};

@RootCommand({
Expand Down Expand Up @@ -58,7 +61,15 @@ export class CortexCommand extends CommandRunner {
const host = options?.address || defaultCortexJsHost;
const port = options?.port || defaultCortexJsPort;
const showLogs = options?.logs || false;
const showVersion = options?.version || false;
const dataFolderPath = options?.dataFolder;
if (showVersion) {
printSlogan();
console.log('\n');
console.log(`Cortex CLI - v${pkg.version}`);
console.log(chalk.blue(`Github: ${pkg.homepage}`));
return;
}
return this.startServer(host, port, showLogs, dataFolderPath);
}

Expand Down Expand Up @@ -156,4 +167,12 @@ export class CortexCommand extends CommandRunner {
parseDataFolder(value: string) {
return value;
}

@Option({
flags: '-v, --version',
description: 'Show version',
})
parseVersion() {
return true;
}
}

0 comments on commit b66b761

Please sign in to comment.