Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
5bfdc2e2
Commit
5bfdc2e2
authored
Nov 30, 2014
by
Christian Couder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --quiet option to ipfs add
License: MIT Signed-off-by:
Christian Couder
<
chriscool@tuxfamily.org
>
parent
ff23d2d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
core/commands/add.go
core/commands/add.go
+14
-1
No files found.
core/commands/add.go
View file @
5bfdc2e2
...
...
@@ -23,6 +23,7 @@ var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded")
type
AddOutput
struct
{
Objects
[]
*
Object
Names
[]
string
Quiet
bool
}
var
addCmd
=
&
cmds
.
Command
{
...
...
@@ -41,6 +42,7 @@ remains to be implemented.
},
Options
:
[]
cmds
.
Option
{
cmds
.
OptionRecursivePath
,
// a builtin option that allows recursive paths (-r, --recursive)
cmds
.
BoolOption
(
"quiet"
,
"q"
,
"Write minimal output"
),
},
Run
:
func
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
added
:=
&
AddOutput
{}
...
...
@@ -64,6 +66,13 @@ remains to be implemented.
}
}
quiet
,
_
,
err
:=
req
.
Option
(
"quiet"
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
added
.
Quiet
=
quiet
return
added
,
nil
},
Marshalers
:
cmds
.
MarshalerMap
{
...
...
@@ -75,7 +84,11 @@ remains to be implemented.
var
buf
bytes
.
Buffer
for
i
,
obj
:=
range
val
.
Objects
{
buf
.
Write
([]
byte
(
fmt
.
Sprintf
(
"added %s %s
\n
"
,
obj
.
Hash
,
val
.
Names
[
i
])))
if
val
.
Quiet
{
buf
.
Write
([]
byte
(
fmt
.
Sprintf
(
"%s
\n
"
,
obj
.
Hash
)))
}
else
{
buf
.
Write
([]
byte
(
fmt
.
Sprintf
(
"added %s %s
\n
"
,
obj
.
Hash
,
val
.
Names
[
i
])))
}
}
return
buf
.
Bytes
(),
nil
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment