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-unixfs
Commits
79b88ee0
Commit
79b88ee0
authored
Nov 04, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands2: Added argument definitions to 'publish'
parent
4765a1d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
core/commands2/publish.go
core/commands2/publish.go
+9
-8
No files found.
core/commands2/publish.go
View file @
79b88ee0
...
...
@@ -11,12 +11,16 @@ import (
u
"github.com/jbenet/go-ipfs/util"
)
type
PublishOutput
struct
{
type
IpnsEntry
struct
{
Name
string
Value
string
}
var
publishCmd
=
&
cmds
.
Command
{
Arguments
:
[]
cmds
.
Argument
{
cmds
.
Argument
{
"name"
,
cmds
.
ArgString
,
false
,
false
},
cmds
.
Argument
{
"object"
,
cmds
.
ArgString
,
true
,
false
},
},
Help
:
"TODO"
,
Run
:
func
(
res
cmds
.
Response
,
req
cmds
.
Request
)
{
n
:=
req
.
Context
()
.
Node
...
...
@@ -39,9 +43,6 @@ var publishCmd = &cmds.Command{
case
1
:
// name = n.Identity.ID.String()
ref
=
args
[
0
]
.
(
string
)
default
:
res
.
SetError
(
fmt
.
Errorf
(
"Publish expects 1 or 2 args; got %d."
,
len
(
args
)),
cmds
.
ErrClient
)
}
// TODO n.Keychain.Get(name).PrivKey
...
...
@@ -56,15 +57,15 @@ var publishCmd = &cmds.Command{
},
Marshallers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaller
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
PublishOutput
)
v
:=
res
.
Output
()
.
(
*
IpnsEntry
)
s
:=
fmt
.
Sprintf
(
"Published name %s to %s
\n
"
,
v
.
Name
,
v
.
Value
)
return
[]
byte
(
s
),
nil
},
},
Type
:
&
PublishOutput
{},
Type
:
&
IpnsEntry
{},
}
func
publish
(
n
*
core
.
IpfsNode
,
k
crypto
.
PrivKey
,
ref
string
)
(
*
PublishOutput
,
error
)
{
func
publish
(
n
*
core
.
IpfsNode
,
k
crypto
.
PrivKey
,
ref
string
)
(
*
IpnsEntry
,
error
)
{
pub
:=
nsys
.
NewRoutingPublisher
(
n
.
Routing
)
err
:=
pub
.
Publish
(
k
,
ref
)
if
err
!=
nil
{
...
...
@@ -76,7 +77,7 @@ func publish(n *core.IpfsNode, k crypto.PrivKey, ref string) (*PublishOutput, er
return
nil
,
err
}
return
&
PublishOutput
{
return
&
IpnsEntry
{
Name
:
u
.
Key
(
hash
)
.
String
(),
Value
:
ref
,
},
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