@@ -14,13 +14,26 @@ function cli(args: string[]) {
1414 ///////////////////////////////////////////////////////////////////////////////
1515 const circuit = new Command ( 'compile' )
1616 . description ( 'compile the circuit' )
17- . argument ( '<circuit>' , 'Circuit name' )
18- // .hook('preAction', () => titleLog('Compiling the circuit'))
19- . action ( async circuit => {
20- const path = await circomkit . compile ( circuit ) ;
21- circomkit . log . info ( 'Built at:' , path ) ;
17+ . argument ( '[pattern]' , 'Circuit name or pattern (defaults to ".*" for all circuits)' )
18+ . action ( async pattern => {
19+ const circuits = circomkit . readCircuits ( ) ;
20+ const circuitNames = Object . keys ( circuits ) ;
21+
22+ if ( ! pattern ) pattern = '.*' ;
23+
24+ const regex = new RegExp ( `^${ pattern } $` ) ;
25+ const matchingCircuits = circuitNames . filter ( name => regex . test ( name ) ) ;
2226
23- // TODO: pattern matching https://github.com/erhant/circomkit/issues/79
27+ if ( matchingCircuits . length === 0 ) {
28+ circomkit . log . info ( 'No circuits found matching pattern:' , pattern ) ;
29+ return ;
30+ }
31+
32+ for ( const circuitName of matchingCircuits ) {
33+ circomkit . log . info ( `Compiling ${ circuitName } ...` ) ;
34+ const path = await circomkit . compile ( circuitName ) ;
35+ circomkit . log . info ( `Built at: ${ path } ` ) ;
36+ }
2437 } ) ;
2538
2639 ///////////////////////////////////////////////////////////////////////////////
0 commit comments