@@ -30,9 +30,15 @@ const (
30
30
31
31
var AddCmd = & cmds.Command {
32
32
Helptext : cmds.HelpText {
33
- Tagline : "Add a file or directory to ipfs." ,
33
+ Tagline : "Add a file to ipfs." ,
34
+ Synopsis : `ipfs add <path> [--quiet | -q] [--silent] [--progress | -p]
35
+ [--trickle |-t] [--wrap-with-directory | -w] [--hidden | -H]
36
+ [--only-hash | -n] [--chunker | -s] [--pin] [--recursive | -r]
37
+ ` ,
34
38
ShortDescription : `
35
- Adds contents of <path> to ipfs. Use -r to add directories (recursively).
39
+ Adds contents of <path> to ipfs. Use -r to add directories.
40
+ Note that directories are added recursively, to form the ipfs
41
+ MerkleDAG.
36
42
` ,
37
43
LongDescription : `
38
44
Adds contents of <path> to ipfs. Use -r to add directories.
@@ -61,29 +67,21 @@ You can now refer to the added file in a gateway, like so:
61
67
},
62
68
Options : []cmds.Option {
63
69
cmds .OptionRecursivePath , // a builtin option that allows recursive paths (-r, --recursive)
64
- cmds .BoolOption (quietOptionName , "q" , "Write minimal output." ),
65
- cmds .BoolOption (silentOptionName , "Write no output." ),
66
- cmds .BoolOption (progressOptionName , "p" , "Stream progress data." ),
67
- cmds .BoolOption (trickleOptionName , "t" , "Use trickle-dag format for dag generation." ),
68
- cmds .BoolOption (onlyHashOptionName , "n" , "Only chunk and hash - do not write to disk." ),
69
- cmds .BoolOption (wrapOptionName , "w" , "Wrap files with a directory object." ),
70
- cmds .BoolOption (hiddenOptionName , "H" , "Include files that are hidden. Only takes effect on recursive add." ),
70
+ cmds .BoolOption (quietOptionName , "q" , "Write minimal output." ). Default ( false ) ,
71
+ cmds .BoolOption (silentOptionName , "Write no output." ). Default ( false ) ,
72
+ cmds .BoolOption (progressOptionName , "p" , "Stream progress data." ). Default ( true ) ,
73
+ cmds .BoolOption (trickleOptionName , "t" , "Use trickle-dag format for dag generation." ). Default ( false ) ,
74
+ cmds .BoolOption (onlyHashOptionName , "n" , "Only chunk and hash - do not write to disk." ). Default ( false ) ,
75
+ cmds .BoolOption (wrapOptionName , "w" , "Wrap files with a directory object." ). Default ( false ) ,
76
+ cmds .BoolOption (hiddenOptionName , "H" , "Include files that are hidden. Only takes effect on recursive add." ). Default ( false ) ,
71
77
cmds .StringOption (chunkerOptionName , "s" , "Chunking algorithm to use." ),
72
- cmds .BoolOption (pinOptionName , "Pin this object when adding. Default: true." ),
78
+ cmds .BoolOption (pinOptionName , "Pin this object when adding." ). Default ( true ),
73
79
},
74
80
PreRun : func (req cmds.Request ) error {
75
81
if quiet , _ , _ := req .Option (quietOptionName ).Bool (); quiet {
76
82
return nil
77
83
}
78
84
79
- // ipfs cli progress bar defaults to true
80
- progress , found , _ := req .Option (progressOptionName ).Bool ()
81
- if ! found {
82
- progress = true
83
- }
84
-
85
- req .SetOption (progressOptionName , progress )
86
-
87
85
sizeFile , ok := req .Files ().(files.SizeFile )
88
86
if ! ok {
89
87
// we don't need to error, the progress bar just won't know how big the files are
@@ -129,11 +127,7 @@ You can now refer to the added file in a gateway, like so:
129
127
hidden , _ , _ := req .Option (hiddenOptionName ).Bool ()
130
128
silent , _ , _ := req .Option (silentOptionName ).Bool ()
131
129
chunker , _ , _ := req .Option (chunkerOptionName ).String ()
132
- dopin , pin_found , _ := req .Option (pinOptionName ).Bool ()
133
-
134
- if ! pin_found { // default
135
- dopin = true
136
- }
130
+ dopin , _ , _ := req .Option (pinOptionName ).Bool ()
137
131
138
132
if hash {
139
133
nilnode , err := core .NewNode (n .Context (), & core.BuildCfg {
@@ -220,7 +214,7 @@ You can now refer to the added file in a gateway, like so:
220
214
return
221
215
}
222
216
223
- progress , prgFound , err := req .Option (progressOptionName ).Bool ()
217
+ progress , _ , err := req .Option (progressOptionName ).Bool ()
224
218
if err != nil {
225
219
res .SetError (u .ErrCast (), cmds .ErrNormal )
226
220
return
@@ -233,9 +227,7 @@ You can now refer to the added file in a gateway, like so:
233
227
}
234
228
235
229
var showProgressBar bool
236
- if prgFound {
237
- showProgressBar = progress
238
- } else if ! quiet && ! silent {
230
+ if ! progress && ! quiet && ! silent {
239
231
showProgressBar = true
240
232
}
241
233
0 commit comments