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-cmds
Commits
df345b49
Commit
df345b49
authored
Apr 05, 2017
by
Jan Winkelmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused Command.fakeOldCall function
parent
65d18cee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
96 deletions
+0
-96
command.go
command.go
+0
-96
No files found.
command.go
View file @
df345b49
...
...
@@ -12,7 +12,6 @@ import (
"errors"
"fmt"
"io"
"reflect"
"github.com/ipfs/go-ipfs-cmds/cmdsutil"
...
...
@@ -110,101 +109,6 @@ func (c *Command) Call(req Request, re ResponseEmitter) error {
return
nil
}
func
(
c
*
Command
)
fakeOldCall
(
cmd
*
oldcmds
.
Command
,
req
Request
,
re
ResponseEmitter
)
error
{
if
cmd
.
Run
==
nil
{
return
ErrNotCallable
}
// fake old response
res
:=
&
fakeResponse
{
re
:
re
,
req
:
&
requestWrapper
{
req
},
}
optDefs
:=
make
(
map
[
string
]
cmdsutil
.
Option
)
for
k
,
v
:=
range
req
.
Options
()
{
optDefs
[
k
]
=
v
.
(
cmdsutil
.
Option
)
}
// fake old request
oldReq
,
err
:=
oldcmds
.
NewRequest
(
req
.
Path
(),
req
.
Options
(),
req
.
StringArguments
(),
req
.
Files
(),
cmd
,
optDefs
,
)
if
err
!=
nil
{
return
err
}
err
=
cmd
.
CheckArguments
(
oldReq
)
if
err
!=
nil
{
return
err
}
err
=
oldReq
.
ConvertOptions
()
if
err
!=
nil
{
return
err
}
// do what we always did before
cmd
.
Run
(
oldReq
,
res
)
if
res
.
Error
()
!=
nil
{
return
res
.
Error
()
}
output
:=
res
.
Output
()
// check if output is channel
isChan
:=
false
actualType
:=
reflect
.
TypeOf
(
output
)
if
actualType
!=
nil
{
if
actualType
.
Kind
()
==
reflect
.
Ptr
{
actualType
=
actualType
.
Elem
()
}
// test if output is a channel
isChan
=
actualType
.
Kind
()
==
reflect
.
Chan
}
if
isChan
{
if
ch
,
ok
:=
output
.
(
<-
chan
interface
{});
ok
{
output
=
ch
}
else
if
ch
,
ok
:=
output
.
(
chan
interface
{});
ok
{
output
=
(
<-
chan
interface
{})(
ch
)
}
else
{
re
.
SetError
(
ErrIncorrectType
,
cmdsutil
.
ErrNormal
)
return
ErrIncorrectType
}
go
func
()
{
for
v
:=
range
output
.
(
<-
chan
interface
{})
{
re
.
Emit
(
v
)
}
}()
}
else
{
// If the command specified an output type, ensure the actual value
// returned is of that type
if
cmd
.
Type
!=
nil
&&
!
isChan
{
expectedType
:=
reflect
.
TypeOf
(
cmd
.
Type
)
if
actualType
!=
expectedType
{
re
.
SetError
(
ErrIncorrectType
,
cmdsutil
.
ErrNormal
)
return
ErrIncorrectType
}
}
re
.
Emit
(
output
)
}
return
nil
}
// Resolve returns the subcommands at the given path
func
(
c
*
Command
)
Resolve
(
pth
[]
string
)
([]
*
Command
,
error
)
{
cmds
:=
make
([]
*
Command
,
len
(
pth
)
+
1
)
...
...
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