@@ -37,11 +37,9 @@ const (
37
37
38
38
var AddCmd = & cmds.Command {
39
39
Helptext : cmds.HelpText {
40
- Tagline : "Add a file to ipfs." ,
40
+ Tagline : "Add a file or directory to ipfs." ,
41
41
ShortDescription : `
42
- Adds contents of <path> to ipfs. Use -r to add directories.
43
- Note that directories are added recursively, to form the ipfs
44
- MerkleDAG.
42
+ Adds contents of <path> to ipfs. Use -r to add directories (recursively).
45
43
` ,
46
44
LongDescription : `
47
45
Adds contents of <path> to ipfs. Use -r to add directories.
@@ -70,22 +68,26 @@ You can now refer to the added file in a gateway, like so:
70
68
},
71
69
Options : []cmds.Option {
72
70
cmds .OptionRecursivePath , // a builtin option that allows recursive paths (-r, --recursive)
73
- cmds .BoolOption (quietOptionName , "q" , "Write minimal output." ). Default ( false ) ,
74
- cmds .BoolOption (silentOptionName , "Write no output." ). Default ( false ) ,
71
+ cmds .BoolOption (quietOptionName , "q" , "Write minimal output." ),
72
+ cmds .BoolOption (silentOptionName , "Write no output." ),
75
73
cmds .BoolOption (progressOptionName , "p" , "Stream progress data." ),
76
- cmds .BoolOption (trickleOptionName , "t" , "Use trickle-dag format for dag generation." ). Default ( false ) ,
77
- cmds .BoolOption (onlyHashOptionName , "n" , "Only chunk and hash - do not write to disk." ). Default ( false ) ,
78
- cmds .BoolOption (wrapOptionName , "w" , "Wrap files with a directory object." ). Default ( false ) ,
79
- cmds .BoolOption (hiddenOptionName , "H" , "Include files that are hidden. Only takes effect on recursive add." ). Default ( false ) ,
74
+ cmds .BoolOption (trickleOptionName , "t" , "Use trickle-dag format for dag generation." ),
75
+ cmds .BoolOption (onlyHashOptionName , "n" , "Only chunk and hash - do not write to disk." ),
76
+ cmds .BoolOption (wrapOptionName , "w" , "Wrap files with a directory object." ),
77
+ cmds .BoolOption (hiddenOptionName , "H" , "Include files that are hidden. Only takes effect on recursive add." ),
80
78
cmds .StringOption (chunkerOptionName , "s" , "Chunking algorithm to use." ),
81
79
cmds .BoolOption (pinOptionName , "Pin this object when adding." ).Default (true ),
82
80
cmds .BoolOption (rawLeavesOptionName , "Use raw blocks for leaf nodes. (experimental)" ),
83
81
},
84
82
PreRun : func (req cmds.Request ) error {
85
- if quiet , _ , _ := req .Option (quietOptionName ).Bool (); quiet {
83
+ quiet , _ , _ := req .Option (quietOptionName ).Bool ()
84
+ silent , _ , _ := req .Option (silentOptionName ).Bool ()
85
+
86
+ if quiet || silent {
86
87
return nil
87
88
}
88
89
90
+ // ipfs cli progress bar defaults to true unless quiet or silent is used
89
91
_ , found , _ := req .Option (progressOptionName ).Bool ()
90
92
if ! found {
91
93
req .SetOption (progressOptionName , true )
@@ -252,16 +254,6 @@ You can now refer to the added file in a gateway, like so:
252
254
return
253
255
}
254
256
255
- silent , _ , err := req .Option (silentOptionName ).Bool ()
256
- if err != nil {
257
- res .SetError (u .ErrCast (), cmds .ErrNormal )
258
- return
259
- }
260
-
261
- if ! quiet && ! silent {
262
- progress = true
263
- }
264
-
265
257
var bar * pb.ProgressBar
266
258
if progress {
267
259
bar = pb .New64 (0 ).SetUnits (pb .U_BYTES )
0 commit comments