1
+ import pkg from '@/../package.json' ;
1
2
import { RootCommand , CommandRunner , Option } from 'nest-commander' ;
2
3
import { ChatCommand } from './chat.command' ;
3
4
import { ModelsCommand } from './models.command' ;
@@ -18,13 +19,15 @@ import { FileManagerService } from '../services/file-manager/file-manager.servic
18
19
import { CortexUsecases } from '@/usecases/cortex/cortex.usecases' ;
19
20
import { ServeStopCommand } from './sub-commands/serve-stop.command' ;
20
21
import ora from 'ora' ;
22
+ import { printSlogan } from '@/utils/logo' ;
21
23
import { EnginesSetCommand } from './engines/engines-set.command' ;
22
24
23
25
type ServeOptions = {
24
26
address ?: string ;
25
27
port ?: number ;
26
28
logs ?: boolean ;
27
29
dataFolder ?: string ;
30
+ version ?: boolean ;
28
31
} ;
29
32
30
33
@RootCommand ( {
@@ -58,7 +61,15 @@ export class CortexCommand extends CommandRunner {
58
61
const host = options ?. address || defaultCortexJsHost ;
59
62
const port = options ?. port || defaultCortexJsPort ;
60
63
const showLogs = options ?. logs || false ;
64
+ const showVersion = options ?. version || false ;
61
65
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
+ }
62
73
return this . startServer ( host , port , showLogs , dataFolderPath ) ;
63
74
}
64
75
@@ -156,4 +167,12 @@ export class CortexCommand extends CommandRunner {
156
167
parseDataFolder ( value : string ) {
157
168
return value ;
158
169
}
170
+
171
+ @Option ( {
172
+ flags : '-v, --version' ,
173
+ description : 'Show version' ,
174
+ } )
175
+ parseVersion ( ) {
176
+ return true ;
177
+ }
159
178
}
0 commit comments