File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
- import { Command } from 'commander' ;
2
- import { diagnostics } from './commands/diagnostics' ;
1
+ import { Command , Option } from 'commander' ;
2
+ import { diagnostics , logLevels } from './commands/diagnostics' ;
3
3
4
4
function getVersion ( ) : string {
5
5
const { version } : { version : string } = require ( '../package.json' ) ;
@@ -13,7 +13,12 @@ function getVersion(): string {
13
13
program
14
14
. command ( 'diagnostics [workspace]' )
15
15
. description ( 'Print all diagnostics' )
16
- . option ( '-l, --log-level <logLevel>' , 'Log level to print' , 'WARN' )
16
+ . addOption (
17
+ new Option ( '-l, --log-level <logLevel>' , 'Log level to print' )
18
+ . default ( 'WARN' )
19
+ // logLevels is readonly array but .choices need read-write array (because of weak typing)
20
+ . choices ( ( logLevels as unknown ) as string [ ] )
21
+ )
17
22
. action ( async ( workspace , options ) => {
18
23
const logLevelOption : unknown = options . logLevel ;
19
24
if (
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ import chalk from 'chalk';
24
24
import { codeFrameColumns , SourceLocation } from '@babel/code-frame' ;
25
25
import { Range } from 'vscode-languageclient' ;
26
26
27
- export type LogLevel = 'ERROR' | 'WARN' | 'INFO' | 'HINT' ;
27
+ export type LogLevel = typeof logLevels [ number ] ;
28
+ export const logLevels = [ 'ERROR' , 'WARN' , 'INFO' , 'HINT' ] as const ;
28
29
29
30
export async function diagnostics ( workspace : string | null , logLevel : LogLevel ) {
30
31
console . log ( '====================================' ) ;
You can’t perform that action at this time.
0 commit comments