@@ -10,6 +10,7 @@ const zip = require('pull-zip')
1010const getFolderSize = require ( 'get-folder-size' )
1111const byteman = require ( 'byteman' )
1212const waterfall = require ( 'async/waterfall' )
13+ const mh = require ( 'multihashes' )
1314const utils = require ( '../../utils' )
1415const print = require ( '../../utils' ) . print
1516const createProgressBar = require ( '../../utils' ) . createProgressBar
@@ -162,6 +163,11 @@ module.exports = {
162163 type : 'integer' ,
163164 describe : 'Cid version. Non-zero value will change default of \'raw-leaves\' to true. (experimental)'
164165 } ,
166+ hash : {
167+ type : 'string' ,
168+ choices : Object . keys ( mh . names ) ,
169+ describe : 'Hash function to use. Will set Cid version to 1 if used. (experimental)'
170+ } ,
165171 quiet : {
166172 alias : 'q' ,
167173 type : 'boolean' ,
@@ -191,7 +197,8 @@ module.exports = {
191197 : Infinity ,
192198 cidVersion : argv . cidVersion ,
193199 rawLeaves : argv . rawLeaves ,
194- onlyHash : argv . onlyHash
200+ onlyHash : argv . onlyHash ,
201+ hashAlg : argv . hash
195202 }
196203
197204 // Temporary restriction on raw-leaves:
@@ -206,6 +213,18 @@ module.exports = {
206213 throw new Error ( 'Implied argument raw-leaves must be passed and set to false when cid-version is > 0' )
207214 }
208215
216+ // Temporary restriction on raw-leaves:
217+ // When hash != undefined then raw-leaves MUST be present and false.
218+ //
219+ // This is because raw-leaves is not yet implemented in js-ipfs,
220+ // and go-ipfs changes the value of raw-leaves to true when
221+ // hash != undefined unless explicitly set to false.
222+ //
223+ // This retains feature parity without having to implement raw-leaves.
224+ if ( options . hash && options . rawLeaves !== false ) {
225+ throw new Error ( 'Implied argument raw-leaves must be passed and set to false when hash argument is specified' )
226+ }
227+
209228 if ( options . rawLeaves ) {
210229 throw new Error ( 'Not implemented: raw-leaves' )
211230 }
0 commit comments