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
9de01007
Commit
9de01007
authored
Nov 19, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands: pin ls: Accept 'type' option to specify type of pinned keys to list
parent
e6091be0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
core/commands/pin.go
core/commands/pin.go
+28
-3
No files found.
core/commands/pin.go
View file @
9de01007
...
...
@@ -6,6 +6,7 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/merkledag"
u
"github.com/jbenet/go-ipfs/util"
)
var
pinCmd
=
&
cmds
.
Command
{
...
...
@@ -109,15 +110,39 @@ or recursively pinned are not included in the list.
`
,
},
Options
:
[]
cmds
.
Option
{
cmds
.
StringOption
(
"type"
,
"t"
,
"The type of pinned keys to list. Can be
\"
direct
\"
,
\"
indirect
\"
,
\"
recursive
\"
, or
\"
all
\"
"
),
},
Run
:
func
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
n
,
err
:=
req
.
Context
()
.
GetNode
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
KeyList
{
Keys
:
n
.
Pinning
.
Set
()
.
GetKeys
(),
},
nil
typeStr
,
found
,
err
:=
req
.
Option
(
"type"
)
.
String
()
if
err
!=
nil
{
return
nil
,
err
}
if
!
found
{
typeStr
=
"all"
}
if
typeStr
!=
"all"
&&
typeStr
!=
"direct"
&&
typeStr
!=
"indirect"
&&
typeStr
!=
"recursive"
{
return
nil
,
cmds
.
ClientError
(
"Invalid type '"
+
typeStr
+
"', must be
\"
direct
\"
,
\"
indirect
\"
,
\"
recursive
\"
, or
\"
all
\"
"
)
}
keys
:=
make
([]
u
.
Key
,
0
)
if
typeStr
==
"direct"
||
typeStr
==
"all"
{
keys
=
append
(
keys
,
n
.
Pinning
.
DirectKeys
()
...
)
}
if
typeStr
==
"indirect"
||
typeStr
==
"all"
{
keys
=
append
(
keys
,
n
.
Pinning
.
IndirectKeys
()
...
)
}
if
typeStr
==
"recursive"
||
typeStr
==
"all"
{
keys
=
append
(
keys
,
n
.
Pinning
.
RecursiveKeys
()
...
)
}
return
&
KeyList
{
Keys
:
keys
},
nil
},
Type
:
&
KeyList
{},
Marshalers
:
cmds
.
MarshalerMap
{
...
...
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