@@ -53,14 +53,12 @@ export function parseArgs(args: string[]): ParsedArgs {
5353 } ,
5454 } ;
5555
56- let i = 0 ;
57- while ( i < args . length ) {
58- const arg = args [ i ] ;
56+ for ( let i = 0 ; i < args . length ; i ++ ) {
57+ const arg = args [ i ] ! ;
5958
6059 // Check for SQL-style query (starts with SELECT)
6160 if ( arg . toUpperCase ( ) . startsWith ( 'SELECT ' ) ) {
6261 result . query = [ 'sql' , arg ] ;
63- i ++ ;
6462 continue ;
6563 }
6664
@@ -73,10 +71,10 @@ export function parseArgs(args: string[]): ParsedArgs {
7371 result . options . version = true ;
7472 } else if ( arg === '--format' && args [ i + 1 ] ) {
7573 result . options . format = args [ ++ i ] as ParsedArgs [ 'options' ] [ 'format' ] ;
76- } else if ( arg === '-o' || arg === '--output' ) {
74+ } else if ( ( arg === '-o' || arg === '--output' ) && args [ i + 1 ] ) {
7775 result . options . output = args [ ++ i ] as ParsedArgs [ 'options' ] [ 'output' ] ;
78- } else if ( arg === '--limit' || arg === '-n' ) {
79- result . options . limit = parseInt ( args [ ++ i ] , 10 ) ;
76+ } else if ( ( arg === '--limit' || arg === '-n' ) && args [ i + 1 ] ) {
77+ result . options . limit = parseInt ( args [ ++ i ] ! , 10 ) ;
8078 } else if ( arg === 'where' || arg === 'count' || arg === 'between' || arg === 'after' || arg === 'before' ) {
8179 // Query keywords - collect rest as query
8280 result . query = args . slice ( i ) ;
@@ -87,8 +85,6 @@ export function parseArgs(args: string[]): ParsedArgs {
8785 // Assume it's a file
8886 result . files . push ( arg ) ;
8987 }
90-
91- i ++ ;
9288 }
9389
9490 return result ;
0 commit comments