nl_tokens: / * eslint - disable no - param - reassign
pl_tokens: function parseCommandOptions ( command , notManaged ) { let possibleCommandOptions = [ ] ; let possibleCommandOptionsShort = [ ] ; const parsedOptions = { managed : { } , unmanaged : { } , } ; const getName = ( name , option ) => { if ( <mask> ) { return name . length === 1 ? '-' + name : '--' + name ; } const shortOption = option . alias ? ' / ' + bold ( '-' + option . alias ) : '' ; return '--' + option . name + shortOption ; } ; if ( command && command . options ) { const options = objectToArray ( command . options ) ; possibleCommandOptions = options . map ( ( option ) => option . name ) ; possibleCommandOptionsShort = options . reduce ( ( previous , option ) => { if ( option . alias ) { return previous . concat ( option . alias ) ; } return previous ; } , [ ] ) ; options . forEach ( ( option ) => { let value ; let name ; // See if we can match the option against anything. if ( notManaged [ option . name ] !== undefined ) { value = notManaged [ option . name ] ; delete notManaged [ option . name ] ; name = option . name ; } else if ( notManaged [ option . alias ] !== undefined ) { value = notManaged [ option . alias ] ; delete notManaged [ option . alias ] ; name = option . alias ; } if ( value === undefined && option . default ) { value = option . default ; } const converter = option . converter || getInfoObject ( option . validator ) . converter || ( option . default !== undefined && automatic ( option . default ) ) ; if ( value !== undefined && converter ) { value = converter ( value ) ; } // If we have a value and a validator if ( option . validator ) { const validationResult = isValid ( value , option . validator ) ; if ( validationResult !== true ) { try { throwValidationError ( getName ( name , option ) , validationResult , value , 'option' ) ; } catch ( err ) { log . error ( 'A option was not valid.\n\n' + err . message , 'Command Options Problem' ) ; } } } parsedOptions . managed [ option . name ] = value ; } ) ; } parsedOptions . unmanaged = notManaged ; return { possibleCommandOptions , possibleCommandOptionsShort , parsedOptions , finalNotManaged : notManaged , } ; }