@cryptotaxi247 / kubo / commits / 991952850

add: move stdin-name handling to cmds

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Mar 22, 2019 at 00:45 UTC 99195285054599018d13d761447c3549809281e7
1 file changed +4 -16
core/commands/add.go
+4 -16
@@ -36,8 +36,6 @@ const (
36 progressOptionName = "progress"
37 trickleOptionName = "trickle"
38 wrapOptionName = "wrap-with-directory"
39 - stdinPathName = "stdin-name"
40 - hiddenOptionName = "hidden"
39 onlyHashOptionName = "only-hash"
40 chunkerOptionName = "chunker"
41 pinOptionName = "pin"
@@ -114,6 +112,8 @@ You can now check what blocks have been created by:
112 Options: []cmdkit.Option{
113 cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
114 cmds.OptionDerefArgs, // a builtin option that resolves passed in filesystem links (--dereference-args)
115 + cmds.OptionStdinName, // a builtin option that optionally allows wrapping stdin into a named file
116 + cmds.OptionHidden,
117 cmdkit.BoolOption(quietOptionName, "q", "Write minimal output."),
118 cmdkit.BoolOption(quieterOptionName, "Q", "Write only final hash."),
119 cmdkit.BoolOption(silentOptionName, "Write no output."),
@@ -121,8 +121,6 @@ You can now check what blocks have been created by:
121 cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
122 cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
123 cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
124 - cmdkit.StringOption(stdinPathName, "Assign a name if the file source is stdin."),
125 - cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
124 cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
125 cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
126 cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
@@ -162,7 +160,6 @@ You can now check what blocks have been created by:
160 trickle, _ := req.Options[trickleOptionName].(bool)
161 wrap, _ := req.Options[wrapOptionName].(bool)
162 hash, _ := req.Options[onlyHashOptionName].(bool)
165 - //hidden, _ := req.Options[hiddenOptionName].(bool)
163 silent, _ := req.Options[silentOptionName].(bool)
164 chunker, _ := req.Options[chunkerOptionName].(string)
165 dopin, _ := req.Options[pinOptionName].(bool)
@@ -173,7 +170,6 @@ You can now check what blocks have been created by:
170 hashFunStr, _ := req.Options[hashOptionName].(string)
171 inline, _ := req.Options[inlineOptionName].(bool)
172 inlineLimit, _ := req.Options[inlineLimitOptionName].(int)
176 - pathName, _ := req.Options[stdinPathName].(string)
173
174 hashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)]
175 if !ok {
@@ -189,7 +185,7 @@ You can now check what blocks have been created by:
185
186 var toadd files.Node = req.Files
187 name := ""
192 - if !wrap || pathName != "" {
188 + if !wrap {
189 it := req.Files.Entries()
190 if !it.Next() {
191 err := it.Err()
@@ -203,15 +199,7 @@ You can now check what blocks have been created by:
199 name = it.Name()
200 }
201 _, dir := toadd.(files.Directory)
206 - if !dir && pathName != "" {
207 - if wrap {
208 - toadd = files.NewSliceDirectory([]files.DirEntry{
209 - files.FileEntry(pathName, toadd),
210 - })
211 - } else {
212 - name = pathName
213 - }
214 - }
202 +
203
204 opts := []options.UnixfsAddOption{
205 options.Unixfs.Hash(hashFunCode),