import { lint , processFile , isDirectory } from "./utilities" ; const commander = require ( "commander" ) ; const packageJson = require ( "../package.json" ) ; const program = new commander . Command ( ) ; const programBase = program . version ( packageJson . version ) . description ( "jsonld-lint" ) ; programBase . command ( "lint" , { isDefault : true } ) . arguments ( "[fileOrDirectory]" ) . option ( "-r, --recursive" , "recursive file search" , false ) . option ( "-f, --fileExtensionFilter <extension>" , "file extension filter" , ".jsonld" ) . action ( async ( _ , cmd ? ) => { if ( ! cmd ?. args [ 0 ] ) { programBase . help ( ) ; process . exit ( 0 ) ; } if ( await lint ( cmd ?. args [ 0 ] , cmd . recursive , cmd . fileExtensionFilter ) ) { process . exit ( 1 ) ; } process . exit ( 0 ) ; } ) ; programBase . command ( "process" ) . arguments ( "[file]" ) . action ( async ( file ? ) => { if ( ! file ) { programBase . help ( ) ; process . exit ( 0 ) ; } if ( isDirectory ( file ) ) { console . log ( "Supplied parameter is a directory not a file" ) ; process . exit ( 0 ) ; } if ( await processFile ( file ) ) { process . exit ( 1 ) ; } process . exit ( 0 ) ; } ) ; programBase . parse ( process . argv ) ; if ( ! programBase . args . length ) { programBase . help ( ) ; }