Skip to content

Commit

Permalink
Revert da4a4ac and add more longDesc
Browse files Browse the repository at this point in the history
This reverts most of the changes in da4a4ac, which were later found to be errorful. See #2657 for details.

License: MIT
Signed-off-by: Richard Littauer <richard.littauer@gmail.com>
  • Loading branch information
RichardLitt committed Sep 1, 2016
1 parent 6fdfaaf commit 85c6088
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ const (

var AddCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Add a file to ipfs.",
Tagline: "Add a file or directory to ipfs.",
ShortDescription: `
Adds contents of <path> to ipfs. Use -r to add directories.
Note that directories are added recursively, to form the ipfs
MerkleDAG.
Adds contents of <path> to ipfs. Use -r to add directories, recursively.
`,
LongDescription: `
Adds contents of <path> to ipfs. Use -r to add directories.
Note that directories are added recursively, to form the ipfs
MerkleDAG.
Adds contents of <path> to ipfs. Use -r to add directories, recursively.
Files and directories will be chunked and imported into ipfs. File chunks
and directory entries will be linked with cryptographic hashes, forming
an ipfs merkledag. For more information about how file importing works
and the merkledag data structures, see <link>.
The wrap option, '-w', wraps the file (or files, if using the
recursive option) in a directory. This directory contains only
Expand All @@ -69,13 +70,13 @@ You can now refer to the added file in a gateway, like so:
},
Options: []cmds.Option{
cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
cmds.BoolOption(quietOptionName, "q", "Write minimal output.").Default(false),
cmds.BoolOption(silentOptionName, "Write no output.").Default(false),
cmds.BoolOption(quietOptionName, "q", "Write minimal output."),
cmds.BoolOption(silentOptionName, "Write no output."),
cmds.BoolOption(progressOptionName, "p", "Stream progress data."),
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation.").Default(false),
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk.").Default(false),
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object.").Default(false),
cmds.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add.").Default(false),
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
cmds.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
cmds.StringOption(chunkerOptionName, "s", "Chunking algorithm to use."),
cmds.BoolOption(pinOptionName, "Pin this object when adding.").Default(true),
},
Expand Down Expand Up @@ -242,7 +243,7 @@ You can now refer to the added file in a gateway, like so:
return
}

progress, _, err := req.Option(progressOptionName).Bool()
progress, prgFound, err := req.Option(progressOptionName).Bool()
if err != nil {
res.SetError(u.ErrCast(), cmds.ErrNormal)
return
Expand All @@ -254,12 +255,15 @@ You can now refer to the added file in a gateway, like so:
return
}

if !quiet && !silent {
progress = true
var showProgressbar bool
if prgFound {
showProgressbar = progress
} else if !quiet && !silent {
showProgressbar = true
}

var bar *pb.ProgressBar
if progress {
if showProgressbar {
bar = pb.New64(0).SetUnits(pb.U_BYTES)
bar.ManualUpdate = true
bar.ShowTimeLeft = false
Expand All @@ -286,7 +290,7 @@ You can now refer to the added file in a gateway, like so:
}
output := out.(*coreunix.AddedObject)
if len(output.Hash) > 0 {
if progress {
if showProgressbar {
// clear progress bar line before we print "added x" output
fmt.Fprintf(res.Stderr(), "\033[2K\r")
}
Expand All @@ -299,7 +303,7 @@ You can now refer to the added file in a gateway, like so:
} else {
log.Debugf("add progress: %v %v\n", output.Name, output.Bytes)

if !progress {
if !showProgressbar {
continue
}

Expand All @@ -315,11 +319,11 @@ You can now refer to the added file in a gateway, like so:
totalProgress = bar.Add64(delta)
}

if progress {
if showProgressbar {
bar.Update()
}
case size := <-sizeChan:
if progress {
if showProgressbar {
bar.Total = size
bar.ShowPercent = true
bar.ShowBar = true
Expand Down

0 comments on commit 85c6088

Please sign in to comment.