11import { Command , EnumType , ulid } from './deps.ts'
22
3- import { config } from './lib/config.ts'
3+ import { Config } from './lib/config.ts'
44import { logger , LogLevel } from './lib/logger.ts'
55
6+ const LogLevelType = new EnumType ( LogLevel )
7+
68export const cmd = new Command ( )
79 . globalOption ( '--session-id <sessionId:string>' , 'Session Id' , {
810 default : ulid ( ) as string ,
911 // action: ({ sessionId }) => logger.setSessionId(sessionId),
1012 } )
11- . globalType ( 'log-level' , new EnumType ( LogLevel ) )
13+ . globalType ( 'log-level' , LogLevelType )
1214 . globalOption ( '--log-level <level:log-level>' , 'Log level' , {
13- default : LogLevel . DEBUG ,
15+ default : LogLevelType . values ( ) . at ( LogLevelType . values ( ) . indexOf ( LogLevel . DEBUG ) ) ,
1416 action : ( { logLevel } ) => logger . setLogLevel ( logLevel ) ,
1517 } )
16- . globalOption ( '-c, --config-path <configPath:string>' , 'Path to config file' , {
17- action : async ( { configPath } ) => {
18- if ( configPath ) { const cfg = await config . mergeConfig ( configPath ) }
19- } ,
20- } )
18+ . globalOption ( '-c, --config-path <configPath:string>' , 'Path to config file' )
2119 . globalEnv ( 'RUNREAL_ENGINE_PATH=<enginePath:string>' , 'Overide path to engine folder' , { prefix : 'RUNREAL_' } )
2220 . globalOption ( '--engine-path <enginePath:string>' , 'Path to engine folder' )
2321 . globalEnv ( 'RUNREAL_PROJECT_PATH=<projectPath:string>' , 'Overide path to project folder' , { prefix : 'RUNREAL_' } )
@@ -26,3 +24,7 @@ export const cmd = new Command()
2624 . globalOption ( '--build-id <buildId:string>' , 'Overide build ID' )
2725 . globalEnv ( 'RUNREAL_BUILD_PATH=<buildPath:string>' , 'Overide path to build output folder' , { prefix : 'RUNREAL_' } )
2826 . globalOption ( '--build-path <buildPath:string>' , 'Path to save build outputs' )
27+ . globalAction ( async ( options ) => {
28+ // We load the config here so that the singleton should be instantiated before any command is run
29+ await Config . create ( { path : options . configPath } )
30+ } )
0 commit comments