@@ -13,6 +13,7 @@ interface WrapCommand {
1313 openAttestationV3 : boolean ;
1414 unwrap : boolean ;
1515 silent ?: boolean ;
16+ batched : boolean ;
1617}
1718
1819export const command = "wrap <raw-documents-path> [options]" ;
@@ -61,9 +62,14 @@ export const builder = (yargs: Argv): Argv =>
6162 alias : "silent" ,
6263 description : "Disable console outputs when outputting to stdout" ,
6364 type : "boolean" ,
65+ } )
66+ . option ( "batched" , {
67+ description : "Indicate whether documents must be wrap together or individually" ,
68+ type : "boolean" ,
69+ default : true ,
6470 } ) ;
6571
66- export const handler = async ( args : WrapCommand ) : Promise < string > => {
72+ export const handler = async ( args : WrapCommand ) : Promise < string | undefined > => {
6773 try {
6874 const outputPathType = args . outputDir ? Output . Directory : args . outputFile ? Output . File : Output . StdOut ;
6975 const outputPath = args . outputDir || args . outputFile ; // undefined when we use std out
@@ -83,16 +89,27 @@ export const handler = async (args: WrapCommand): Promise<string> => {
8389 signale . disable ( ) ;
8490 }
8591
92+ // if output to a file or stdout, we handle only one file. In that case we disable the batch mode
93+ const batched = outputPathType !== Output . Directory ? false : args . batched ;
94+ if ( ! batched && args . batched ) {
95+ signale . warn ( "Detected single file: batch mode disabled." ) ;
96+ }
97+
8698 const merkleRoot = await wrap ( {
8799 inputPath : args . rawDocumentsPath ,
88100 outputPath,
89101 schemaPath : args . schema ,
90102 version : args . openAttestationV3 ? SchemaId . v3 : SchemaId . v2 ,
91103 unwrap : args . unwrap ,
92104 outputPathType,
105+ batched,
93106 } ) ;
94107
95- signale . success ( `Batch Document Root: 0x${ merkleRoot } ` ) ;
108+ if ( merkleRoot ) {
109+ signale . success ( `Batch Document Root: 0x${ merkleRoot } ` ) ;
110+ } else {
111+ signale . success ( "All documents have been individually wrapped" ) ;
112+ }
96113
97114 return merkleRoot ;
98115 } catch ( err ) {
0 commit comments