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
d1f1d2f5
Commit
d1f1d2f5
authored
10 years ago
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands2: Fixed commands to use string arguments
parent
f8be2681
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
23 additions
and
101 deletions
+23
-101
cmd/ipfs2/tour.go
cmd/ipfs2/tour.go
+2
-8
core/commands2/block.go
core/commands2/block.go
+1
-4
core/commands2/bootstrap.go
core/commands2/bootstrap.go
+2
-11
core/commands2/cat.go
core/commands2/cat.go
+1
-7
core/commands2/config.go
core/commands2/config.go
+2
-11
core/commands2/log.go
core/commands2/log.go
+1
-5
core/commands2/ls.go
core/commands2/ls.go
+1
-5
core/commands2/object.go
core/commands2/object.go
+7
-22
core/commands2/pin.go
core/commands2/pin.go
+2
-13
core/commands2/publish.go
core/commands2/publish.go
+2
-2
core/commands2/refs.go
core/commands2/refs.go
+1
-7
core/commands2/resolve.go
core/commands2/resolve.go
+1
-6
No files found.
cmd/ipfs2/tour.go
View file @
d1f1d2f5
...
...
@@ -9,7 +9,6 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
config
"github.com/jbenet/go-ipfs/config"
internal
"github.com/jbenet/go-ipfs/core/commands2/internal"
tour
"github.com/jbenet/go-ipfs/tour"
)
...
...
@@ -43,14 +42,9 @@ func tourRunFunc(req cmds.Request) (interface{}, error) {
return
nil
,
err
}
strs
,
err
:=
internal
.
CastToStrings
(
req
.
Arguments
())
if
err
!=
nil
{
return
nil
,
err
}
id
:=
tour
.
TopicID
(
cfg
.
Tour
.
Last
)
if
len
(
strs
)
>
0
{
id
=
tour
.
TopicID
(
strs
[
0
])
if
len
(
req
.
Arguments
()
)
>
0
{
id
=
tour
.
TopicID
(
req
.
Arguments
()
[
0
])
}
var
w
bytes
.
Buffer
...
...
This diff is collapsed.
Click to expand it.
core/commands2/block.go
View file @
d1f1d2f5
...
...
@@ -52,10 +52,7 @@ It outputs to stdout, and <key> is a base58 encoded multihash.
return
nil
,
err
}
key
,
ok
:=
req
.
Arguments
()[
0
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
key
:=
req
.
Arguments
()[
0
]
if
!
u
.
IsValidHash
(
key
)
{
return
nil
,
cmds
.
Error
{
"Not a valid hash"
,
cmds
.
ErrClient
}
...
...
This diff is collapsed.
Click to expand it.
core/commands2/bootstrap.go
View file @
d1f1d2f5
...
...
@@ -184,16 +184,7 @@ func bootstrapWritePeers(w io.Writer, prefix string, peers []*config.BootstrapPe
return
nil
}
func
bootstrapInputToPeers
(
input
[]
interface
{})
([]
*
config
.
BootstrapPeer
,
error
)
{
inputAddrs
:=
make
([]
string
,
len
(
input
))
for
i
,
v
:=
range
input
{
addr
,
ok
:=
v
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
inputAddrs
[
i
]
=
addr
}
func
bootstrapInputToPeers
(
input
[]
string
)
([]
*
config
.
BootstrapPeer
,
error
)
{
split
:=
func
(
addr
string
)
(
string
,
string
)
{
idx
:=
strings
.
LastIndex
(
addr
,
"/"
)
if
idx
==
-
1
{
...
...
@@ -203,7 +194,7 @@ func bootstrapInputToPeers(input []interface{}) ([]*config.BootstrapPeer, error)
}
peers
:=
[]
*
config
.
BootstrapPeer
{}
for
_
,
addr
:=
range
input
Addrs
{
for
_
,
addr
:=
range
input
{
addrS
,
peeridS
:=
split
(
addr
)
// make sure addrS parses as a multiaddr.
...
...
This diff is collapsed.
Click to expand it.
core/commands2/cat.go
View file @
d1f1d2f5
...
...
@@ -5,7 +5,6 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
core
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/core/commands2/internal"
uio
"github.com/jbenet/go-ipfs/unixfs/io"
)
...
...
@@ -29,12 +28,7 @@ it contains.
readers
:=
make
([]
io
.
Reader
,
0
,
len
(
req
.
Arguments
()))
paths
,
err
:=
internal
.
CastToStrings
(
req
.
Arguments
())
if
err
!=
nil
{
return
nil
,
err
}
readers
,
err
=
cat
(
node
,
paths
)
readers
,
err
=
cat
(
node
,
req
.
Arguments
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
core/commands2/config.go
View file @
d1f1d2f5
...
...
@@ -55,11 +55,7 @@ Set the value of the 'datastore.path' key:
},
Run
:
func
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
args
:=
req
.
Arguments
()
key
,
ok
:=
args
[
0
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
key
:=
args
[
0
]
filename
,
err
:=
config
.
Filename
(
req
.
Context
()
.
ConfigRoot
)
if
err
!=
nil
{
...
...
@@ -68,12 +64,7 @@ Set the value of the 'datastore.path' key:
var
value
string
if
len
(
args
)
==
2
{
var
ok
bool
value
,
ok
=
args
[
1
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
value
=
args
[
1
]
return
setConfig
(
filename
,
key
,
value
)
}
else
{
...
...
This diff is collapsed.
Click to expand it.
core/commands2/log.go
View file @
d1f1d2f5
...
...
@@ -31,11 +31,7 @@ output of a running daemon.
Run
:
func
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
args
:=
req
.
Arguments
()
subsystem
,
ok1
:=
args
[
0
]
.
(
string
)
level
,
ok2
:=
args
[
1
]
.
(
string
)
if
!
ok1
||
!
ok2
{
return
nil
,
u
.
ErrCast
()
}
subsystem
,
level
:=
args
[
0
],
args
[
1
]
if
subsystem
==
logAllKeyword
{
subsystem
=
"*"
...
...
This diff is collapsed.
Click to expand it.
core/commands2/ls.go
View file @
d1f1d2f5
...
...
@@ -4,7 +4,6 @@ import (
"fmt"
cmds
"github.com/jbenet/go-ipfs/commands"
"github.com/jbenet/go-ipfs/core/commands2/internal"
merkledag
"github.com/jbenet/go-ipfs/merkledag"
)
...
...
@@ -42,10 +41,7 @@ it contains, with the following format:
return
nil
,
err
}
paths
,
err
:=
internal
.
CastToStrings
(
req
.
Arguments
())
if
err
!=
nil
{
return
nil
,
err
}
paths
:=
req
.
Arguments
()
dagnodes
:=
make
([]
*
merkledag
.
Node
,
0
)
for
_
,
path
:=
range
paths
{
...
...
This diff is collapsed.
Click to expand it.
core/commands2/object.go
View file @
d1f1d2f5
...
...
@@ -12,7 +12,6 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
core
"github.com/jbenet/go-ipfs/core"
dag
"github.com/jbenet/go-ipfs/merkledag"
u
"github.com/jbenet/go-ipfs/util"
)
// ErrObjectTooLarge is returned when too much data was read from stdin. current limit 512k
...
...
@@ -74,11 +73,7 @@ output is the raw data of the object.
return
nil
,
err
}
key
,
ok
:=
req
.
Arguments
()[
0
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
key
:=
req
.
Arguments
()[
0
]
return
objectData
(
n
,
key
)
},
}
...
...
@@ -102,11 +97,7 @@ multihash.
return
nil
,
err
}
key
,
ok
:=
req
.
Arguments
()[
0
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
key
:=
req
.
Arguments
()[
0
]
return
objectLinks
(
n
,
key
)
},
Marshalers
:
cmds
.
MarshalerMap
{
...
...
@@ -148,10 +139,7 @@ This command outputs data in the following encodings:
return
nil
,
err
}
key
,
ok
:=
req
.
Arguments
()[
0
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
key
:=
req
.
Arguments
()[
0
]
object
,
err
:=
objectGet
(
n
,
key
)
if
err
!=
nil
{
...
...
@@ -214,15 +202,12 @@ Data should be in the format specified by <encoding>.
return
nil
,
err
}
input
,
ok
:=
req
.
Arguments
()[
0
]
.
(
io
.
Reader
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
input
,
err
:=
req
.
Files
()
.
NextFile
(
)
if
err
!=
nil
&&
err
!=
io
.
EOF
{
return
nil
,
err
}
encoding
,
ok
:=
req
.
Arguments
()[
1
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
encoding
:=
req
.
Arguments
()[
0
]
output
,
err
:=
objectPut
(
n
,
input
,
encoding
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
core/commands2/pin.go
View file @
d1f1d2f5
...
...
@@ -5,7 +5,6 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/core/commands2/internal"
"github.com/jbenet/go-ipfs/merkledag"
)
...
...
@@ -50,12 +49,7 @@ on disk.
recursive
=
false
}
paths
,
err
:=
internal
.
CastToStrings
(
req
.
Arguments
())
if
err
!=
nil
{
return
nil
,
err
}
_
,
err
=
pin
(
n
,
paths
,
recursive
)
_
,
err
=
pin
(
n
,
req
.
Arguments
(),
recursive
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -95,12 +89,7 @@ collected if needed.
recursive
=
false
// default
}
paths
,
err
:=
internal
.
CastToStrings
(
req
.
Arguments
())
if
err
!=
nil
{
return
nil
,
err
}
_
,
err
=
unpin
(
n
,
paths
,
recursive
)
_
,
err
=
unpin
(
n
,
req
.
Arguments
(),
recursive
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
core/commands2/publish.go
View file @
d1f1d2f5
...
...
@@ -67,11 +67,11 @@ Publish a <ref> to another public key:
switch
len
(
args
)
{
case
2
:
// name = args[0]
ref
=
args
[
1
]
.
(
string
)
ref
=
args
[
1
]
return
nil
,
errors
.
New
(
"keychains not yet implemented"
)
case
1
:
// name = n.Identity.ID.String()
ref
=
args
[
0
]
.
(
string
)
ref
=
args
[
0
]
}
// TODO n.Keychain.Get(name).PrivKey
...
...
This diff is collapsed.
Click to expand it.
core/commands2/refs.go
View file @
d1f1d2f5
...
...
@@ -6,7 +6,6 @@ import (
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
cmds
"github.com/jbenet/go-ipfs/commands"
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/core/commands2/internal"
dag
"github.com/jbenet/go-ipfs/merkledag"
u
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -57,12 +56,7 @@ Note: list all refs recursively with -r.
recursive
=
false
}
paths
,
err
:=
internal
.
CastToStrings
(
req
.
Arguments
())
if
err
!=
nil
{
return
nil
,
err
}
return
getRefs
(
n
,
paths
,
unique
,
recursive
)
return
getRefs
(
n
,
req
.
Arguments
(),
unique
,
recursive
)
},
Type
:
&
RefsOutput
{},
Marshalers
:
cmds
.
MarshalerMap
{
...
...
This diff is collapsed.
Click to expand it.
core/commands2/resolve.go
View file @
d1f1d2f5
...
...
@@ -4,7 +4,6 @@ import (
"errors"
cmds
"github.com/jbenet/go-ipfs/commands"
u
"github.com/jbenet/go-ipfs/util"
)
var
resolveCmd
=
&
cmds
.
Command
{
...
...
@@ -59,11 +58,7 @@ Resolve te value of another name:
name
=
n
.
Identity
.
ID
()
.
String
()
}
else
{
var
ok
bool
name
,
ok
=
req
.
Arguments
()[
0
]
.
(
string
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
name
=
req
.
Arguments
()[
0
]
}
output
,
err
:=
n
.
Namesys
.
Resolve
(
name
)
...
...
This diff is collapsed.
Click to expand it.
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