@@ -202,55 +202,60 @@ const program = cli({
202202const main = async ( ) => {
203203 const { command, options } = await program . execute ( { args : process . argv } ) ;
204204
205- switch ( command ) {
206- case null : {
207- await generateApi ( {
208- name : options . name ,
209- url : options . path ,
210- generateRouteTypes : options . routeTypes ,
211- generateClient : ! ! ( options . axios || options . client ) ,
212- httpClientType : options . axios ? HTTP_CLIENT . AXIOS : HTTP_CLIENT . FETCH ,
213- defaultResponseAsSuccess : options . defaultAsSuccess ,
214- defaultResponseType : options . defaultResponse ,
215- unwrapResponseData : options . unwrapResponseData ,
216- disableThrowOnError : options . disableThrowOnError ,
217- sortTypes : options . sortTypes ,
218- generateUnionEnums : options . unionEnums ,
219- addReadonly : options . addReadonly ,
220- generateResponses : options . responses ,
221- extractRequestParams : ! ! options . extractRequestParams ,
222- extractRequestBody : ! ! options . extractRequestBody ,
223- extractResponseBody : ! ! options . extractResponseBody ,
224- extractResponseError : ! ! options . extractResponseError ,
225- input : resolve ( process . cwd ( ) , options . path ) ,
226- output : resolve ( process . cwd ( ) , options . output || "." ) ,
227- templates : options . templates ,
228- modular : ! ! options . modular ,
229- toJS : ! ! options . js ,
230- enumNamesAsValues : options . enumNamesAsValues ,
231- moduleNameIndex : + ( options . moduleNameIndex || 0 ) ,
232- moduleNameFirstTag : options . moduleNameFirstTag ,
233- disableStrictSSL : ! ! options . disableStrictSSL ,
234- disableProxy : ! ! options . disableProxy ,
235- singleHttpClient : ! ! options . singleHttpClient ,
236- cleanOutput : ! ! options . cleanOutput ,
237- silent : ! ! options . silent ,
238- typePrefix : options . typePrefix ,
239- typeSuffix : options . typeSuffix ,
240- patch : ! ! options . patch ,
241- apiClassName : options . apiClassName ,
242- debug : options . debug ,
243- anotherArrayType : options . anotherArrayType ,
244- } ) ;
245- break ;
246- }
247- case "generate-templates" : {
248- console . info ( "todo" ) ;
249- break ;
250- }
251- default : {
252- break ;
205+ try {
206+ switch ( command ) {
207+ case null : {
208+ await generateApi ( {
209+ name : options . name ,
210+ url : options . path ,
211+ generateRouteTypes : options . routeTypes ,
212+ generateClient : ! ! ( options . axios || options . client ) ,
213+ httpClientType : options . axios ? HTTP_CLIENT . AXIOS : HTTP_CLIENT . FETCH ,
214+ defaultResponseAsSuccess : options . defaultAsSuccess ,
215+ defaultResponseType : options . defaultResponse ,
216+ unwrapResponseData : options . unwrapResponseData ,
217+ disableThrowOnError : options . disableThrowOnError ,
218+ sortTypes : options . sortTypes ,
219+ generateUnionEnums : options . unionEnums ,
220+ addReadonly : options . addReadonly ,
221+ generateResponses : options . responses ,
222+ extractRequestParams : ! ! options . extractRequestParams ,
223+ extractRequestBody : ! ! options . extractRequestBody ,
224+ extractResponseBody : ! ! options . extractResponseBody ,
225+ extractResponseError : ! ! options . extractResponseError ,
226+ input : resolve ( process . cwd ( ) , options . path ) ,
227+ output : resolve ( process . cwd ( ) , options . output || "." ) ,
228+ templates : options . templates ,
229+ modular : ! ! options . modular ,
230+ toJS : ! ! options . js ,
231+ enumNamesAsValues : options . enumNamesAsValues ,
232+ moduleNameIndex : + ( options . moduleNameIndex || 0 ) ,
233+ moduleNameFirstTag : options . moduleNameFirstTag ,
234+ disableStrictSSL : ! ! options . disableStrictSSL ,
235+ disableProxy : ! ! options . disableProxy ,
236+ singleHttpClient : ! ! options . singleHttpClient ,
237+ cleanOutput : ! ! options . cleanOutput ,
238+ silent : ! ! options . silent ,
239+ typePrefix : options . typePrefix ,
240+ typeSuffix : options . typeSuffix ,
241+ patch : ! ! options . patch ,
242+ apiClassName : options . apiClassName ,
243+ debug : options . debug ,
244+ anotherArrayType : options . anotherArrayType ,
245+ } ) ;
246+ break ;
247+ }
248+ case "generate-templates" : {
249+ console . info ( "todo" ) ;
250+ break ;
251+ }
252+ default : {
253+ break ;
254+ }
253255 }
256+ } catch ( e ) {
257+ console . error ( e ) ;
258+ process . exit ( 1 ) ;
254259 }
255260} ;
256261
0 commit comments