@@ -7,7 +7,7 @@ import { runDemo } from './run-demo.js';
77import { showHelp } from './help.js' ;
88import { checkAllDependencies , showDependencyError } from './check-dependencies.js' ;
99import { login } from './login.js' ;
10- import { searchCommand } from './commands/search.js' ;
10+ import { searchCommand , type SearchOptions } from './commands/search.js' ;
1111import { imageCommand } from './commands/image.js' ;
1212import { musicCommand } from './commands/music.js' ;
1313import { videoCommand } from './commands/video.js' ;
@@ -114,6 +114,7 @@ function parseArgs(): {
114114 paasOptions: PaasOptions ;
115115 paasArgs: string [ ] ;
116116 toolArgs: string ;
117+ searchOptions: SearchOptions ;
117118 memoryOptions: MemoryOptions ;
118119 contactsOptions: ContactsOptionsLocal ;
119120} {
@@ -133,6 +134,7 @@ function parseArgs(): {
133134 paasOptions : { } ,
134135 paasArgs : [ ] ,
135136 toolArgs : '' ,
137+ searchOptions : { } ,
136138 memoryOptions : { } ,
137139 contactsOptions : { } ,
138140 } ;
@@ -189,8 +191,22 @@ function parseArgs(): {
189191 appName = args . find ( ( arg ) => ! arg . startsWith ( '-' ) && arg !== 'create' ) ;
190192 }
191193
192- // Get tool arguments (everything after the command)
193- const toolArgs = process . argv . slice ( 3 ) . filter ( ( arg ) => ! arg . startsWith ( '-' ) ) . join ( ' ' ) ;
194+ // Get tool arguments (everything after the command), excluding flags and their values
195+ const toolArgs = ( ( ) => {
196+ const args = process . argv . slice ( 3 ) ;
197+ const result : string [ ] = [ ] ;
198+ for ( let i = 0 ; i < args . length ; i ++ ) {
199+ if ( args [ i ] . startsWith ( '-' ) ) {
200+ // Skip the flag and its value (if the next arg doesn't start with -)
201+ if ( i + 1 < args . length && ! args [ i + 1 ] . startsWith ( '-' ) ) {
202+ i ++ ;
203+ }
204+ } else {
205+ result . push ( args [ i ] ) ;
206+ }
207+ }
208+ return result . join ( ' ' ) ;
209+ } ) ( ) ;
194210
195211 // Get all values for a repeatable flag (like --db can appear multiple times)
196212 const getAllArgValues = ( flag : string ) : string [ ] => {
@@ -270,6 +286,12 @@ function parseArgs(): {
270286 direction : getArgValue ( '--direction' , '' ) ,
271287 } ;
272288
289+ // Parse search options
290+ const searchOptions : SearchOptions = {
291+ startDate : getArgValue ( '--start-date' , '' ) ,
292+ endDate : getArgValue ( '--end-date' , '' ) ,
293+ } ;
294+
273295 // Parse memory options
274296 const memoryOptions : MemoryOptions = {
275297 path : getArgValue ( '--path' , '' ) ,
@@ -295,12 +317,13 @@ function parseArgs(): {
295317 paasOptions,
296318 paasArgs,
297319 toolArgs,
320+ searchOptions,
298321 memoryOptions,
299322 contactsOptions,
300323 } ;
301324}
302325
303- const { command, subCommand, demoOptions, createOptions, loginOptions, emailOptions, phoneOptions, paasOptions, paasArgs, toolArgs, memoryOptions, contactsOptions } = parseArgs ( ) ;
326+ const { command, subCommand, demoOptions, createOptions, loginOptions, emailOptions, phoneOptions, paasOptions, paasArgs, toolArgs, searchOptions , memoryOptions, contactsOptions } = parseArgs ( ) ;
304327
305328// Extract positional args from argv, skipping flag values (e.g., --path <val> --topk <val>)
306329function extractPositionalArgs ( startIndex : number ) : string {
@@ -367,7 +390,7 @@ async function main() {
367390 break ;
368391
369392 case 'search' :
370- await searchCommand ( toolArgs ) ;
393+ await searchCommand ( toolArgs , searchOptions ) ;
371394 break ;
372395
373396 case 'image' :
0 commit comments