import { flags } from "@oclif/command" ; import { LogLevelDesc } from "loglevel" ; import { ramlToolLogger as logger } from "./logger" ; param options export const logLevel = flags . build ( { description : "[default: info] Set the level of detail in the output" , env : "RAML_TOOLKIT_LOG_LEVEL" , options : Object . keys ( logger . levels ) . map ( ( l ) => l . toLowerCase ( ) ) , parse ( input ) { try { const int = parseInt ( input , 10 ) ; const level = Number . isNaN ( int ) ? input : int ; logger . setLevel ( level as LogLevelDesc ) ; } catch ( err ) { throw new Error ( `Expected --${ this . name }=${ input } to be one of: ${ this . options . join ( ", " ) }` ) ; } return logger . getLevel ( ) ; } , } ) ; param options export function help ( options ? ) { return flags . help ( { char : "h" , description : "Show CLI help" , hidden : true , ... options , } ) ; } param options export function version ( options ? ) { return flags . version ( { description : "Show CLI version" , hidden : true , ... options , } ) ; } example export function allCommonFlags ( ) { return { help : help ( ) , "log-level" : logLevel ( ) , version : version ( ) , } ; }