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
e91b2b8a
Commit
e91b2b8a
authored
Oct 02, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use makeCommand for publish + resolve
parent
330ee8c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
71 deletions
+14
-71
cmd/ipfs/publish.go
cmd/ipfs/publish.go
+7
-36
cmd/ipfs/resolve.go
cmd/ipfs/resolve.go
+7
-35
No files found.
cmd/ipfs/publish.go
View file @
e91b2b8a
package
main
import
(
"os"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
"github.com/jbenet/go-ipfs/core/commands"
"github.com/jbenet/go-ipfs/daemon"
u
"github.com/jbenet/go-ipfs/util"
)
var
cmdIpfsPub
=
&
commander
.
Command
{
...
...
@@ -24,35 +20,10 @@ func init() {
cmdIpfsPub
.
Flag
.
String
(
"k"
,
""
,
"Specify key to use for publishing."
)
}
func
pubCmd
(
c
*
commander
.
Command
,
inp
[]
string
)
error
{
if
len
(
inp
)
<
1
{
u
.
POut
(
c
.
Long
)
return
nil
}
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
cmd
:=
daemon
.
NewCommand
()
cmd
.
Command
=
"publish"
cmd
.
Args
=
inp
cmd
.
Opts
[
"k"
]
=
c
.
Flag
.
Lookup
(
"k"
)
.
Value
.
Get
()
err
=
daemon
.
SendCommand
(
cmd
,
conf
)
if
err
!=
nil
{
u
.
DOut
(
"Executing command locally.
\n
"
)
// Do locally
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
n
,
err
:=
localNode
(
conf
,
true
)
if
err
!=
nil
{
return
err
}
return
commands
.
Publish
(
n
,
cmd
.
Args
,
cmd
.
Opts
,
os
.
Stdout
)
}
return
nil
}
var
pubCmd
=
makeCommand
(
command
{
name
:
"publish"
,
args
:
1
,
flags
:
[]
string
{
"k"
},
online
:
true
,
cmdFn
:
commands
.
Publish
,
})
cmd/ipfs/resolve.go
View file @
e91b2b8a
package
main
import
(
"fmt"
"os"
"time"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
"github.com/jbenet/go-ipfs/core/commands"
"github.com/jbenet/go-ipfs/daemon"
u
"github.com/jbenet/go-ipfs/util"
)
var
cmdIpfsResolve
=
&
commander
.
Command
{
...
...
@@ -22,32 +16,10 @@ var cmdIpfsResolve = &commander.Command{
Flag
:
*
flag
.
NewFlagSet
(
"ipfs-resolve"
,
flag
.
ExitOnError
),
}
func
resolveCmd
(
c
*
commander
.
Command
,
inp
[]
string
)
error
{
if
len
(
inp
)
<
1
{
u
.
POut
(
c
.
Long
)
return
nil
}
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
cmd
:=
daemon
.
NewCommand
()
cmd
.
Command
=
"resolve"
cmd
.
Args
=
inp
err
=
daemon
.
SendCommand
(
cmd
,
conf
)
if
err
!=
nil
{
now
:=
time
.
Now
()
// Resolve requires working DHT
n
,
err
:=
localNode
(
conf
,
true
)
if
err
!=
nil
{
return
err
}
took
:=
time
.
Now
()
.
Sub
(
now
)
fmt
.
Printf
(
"localNode creation took %s
\n
"
,
took
.
String
())
return
commands
.
Resolve
(
n
,
cmd
.
Args
,
cmd
.
Opts
,
os
.
Stdout
)
}
return
nil
}
var
resolveCmd
=
makeCommand
(
command
{
name
:
"resolve"
,
args
:
1
,
flags
:
nil
,
online
:
true
,
cmdFn
:
commands
.
Resolve
,
})
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