1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-20 02:21:48 +08:00

core/commands: Made add command output a channel

core/commands: Don't use pointers for Type field
This commit is contained in:
Matt Bell
2015-01-06 11:36:18 -08:00
parent 69999bd0a7
commit 6236ef7fdb
17 changed files with 23 additions and 23 deletions

View File

@ -102,7 +102,7 @@ remains to be implemented.
}, nil
},
},
Type: &AddedObject{},
Type: AddedObject{},
}
func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {

View File

@ -123,7 +123,7 @@ It reads from stdin, and <key> is a base58 encoded multihash.
Length: len(data),
}, nil
},
Type: &Block{},
Type: Block{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
block := res.Output().(*Block)

View File

@ -112,7 +112,7 @@ in the bootstrap list).
return &BootstrapOutput{added}, nil
},
Type: &BootstrapOutput{},
Type: BootstrapOutput{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
v, ok := res.Output().(*BootstrapOutput)
@ -173,7 +173,7 @@ var bootstrapRemoveCmd = &cmds.Command{
return &BootstrapOutput{removed}, nil
},
Type: &BootstrapOutput{},
Type: BootstrapOutput{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
v, ok := res.Output().(*BootstrapOutput)
@ -203,7 +203,7 @@ var bootstrapListCmd = &cmds.Command{
peers := cfg.Bootstrap
return &BootstrapOutput{peers}, nil
},
Type: &BootstrapOutput{},
Type: BootstrapOutput{},
Marshalers: cmds.MarshalerMap{
cmds.Text: bootstrapMarshaler,
},

View File

@ -36,7 +36,7 @@ func CommandsCmd(root *cmds.Command) *cmds.Command {
return &buf, nil
},
},
Type: &Command{},
Type: Command{},
}
}

View File

@ -95,7 +95,7 @@ Set the value of the 'datastore.path' key:
return bytes.NewReader(buf), nil
},
},
Type: &ConfigField{},
Type: ConfigField{},
Subcommands: map[string]*cmds.Command{
"show": configShowCmd,
"edit": configEditCmd,

View File

@ -84,7 +84,7 @@ connected peers and latencies between them.
return &DiagnosticOutput{output}, nil
},
Type: &DiagnosticOutput{},
Type: DiagnosticOutput{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(r cmds.Response) (io.Reader, error) {
output, ok := r.Output().(*DiagnosticOutput)

View File

@ -91,7 +91,7 @@ if no peer is specified, prints out local peers info.
return bytes.NewReader(marshaled), nil
},
},
Type: &IdOutput{},
Type: IdOutput{},
}
func printPeer(ps peer.Peerstore, p peer.ID) (interface{}, error) {

View File

@ -48,5 +48,5 @@ output of a running daemon.
Marshalers: cmds.MarshalerMap{
cmds.Text: MessageTextMarshaler,
},
Type: &MessageOutput{},
Type: MessageOutput{},
}

View File

@ -89,7 +89,7 @@ it contains, with the following format:
return strings.NewReader(s), nil
},
},
Type: &LsOutput{},
Type: LsOutput{},
}
func marshalLinks(links []Link) (s string) {

View File

@ -133,7 +133,7 @@ baz
output.IPNS = nsdir
return &output, nil
},
Type: &config.Mounts{},
Type: config.Mounts{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
v := res.Output().(*config.Mounts)

View File

@ -108,7 +108,7 @@ multihash.
return strings.NewReader(marshalled), nil
},
},
Type: &Object{},
Type: Object{},
}
var objectGetCmd = &cmds.Command{
@ -162,7 +162,7 @@ This command outputs data in the following encodings:
return node, nil
},
Type: &Node{},
Type: Node{},
Marshalers: cmds.MarshalerMap{
cmds.EncodingType("protobuf"): func(res cmds.Response) (io.Reader, error) {
node := res.Output().(*Node)
@ -232,7 +232,7 @@ Data should be in the format specified by <encoding>.
return strings.NewReader("added " + object.Hash), nil
},
},
Type: &Object{},
Type: Object{},
}
// objectData takes a key string and writes out the raw bytes of that node (if there is one)

View File

@ -157,7 +157,7 @@ Use --type=<type> to specify the type of pinned keys to list. Valid values are:
return &KeyList{Keys: keys}, nil
},
Type: &KeyList{},
Type: KeyList{},
Marshalers: cmds.MarshalerMap{
cmds.Text: KeyListTextMarshaler,
},

View File

@ -86,7 +86,7 @@ Publish a <ref> to another public key:
return strings.NewReader(s), nil
},
},
Type: &IpnsEntry{},
Type: IpnsEntry{},
}
func publish(n *core.IpfsNode, k crypto.PrivKey, ref string) (*IpnsEntry, error) {

View File

@ -71,7 +71,7 @@ Note: list all refs recursively with -r.
return getRefs(n, req.Arguments(), unique, recursive)
},
Type: &KeyList{},
Type: KeyList{},
Marshalers: cmds.MarshalerMap{
cmds.Text: KeyListTextMarshaler,
},

View File

@ -69,7 +69,7 @@ ipfs swarm peers lists the set of peers this node is connected to.
Marshalers: cmds.MarshalerMap{
cmds.Text: stringListMarshaler,
},
Type: &stringList{},
Type: stringList{},
}
var swarmConnectCmd = &cmds.Command{
@ -122,7 +122,7 @@ ipfs swarm connect /ip4/104.131.131.82/tcp/4001/QmaCpDMGvV2BGHeYERUEnRQAwe3N8Szb
Marshalers: cmds.MarshalerMap{
cmds.Text: stringListMarshaler,
},
Type: &stringList{},
Type: stringList{},
}
func stringListMarshaler(res cmds.Response) (io.Reader, error) {

View File

@ -29,7 +29,7 @@ var UpdateCmd = &cmds.Command{
}
return updateApply(n)
},
Type: &UpdateOutput{},
Type: UpdateOutput{},
Subcommands: map[string]*cmds.Command{
"check": UpdateCheckCmd,
"log": UpdateLogCmd,
@ -62,7 +62,7 @@ var UpdateCheckCmd = &cmds.Command{
}
return updateCheck(n)
},
Type: &UpdateOutput{},
Type: UpdateOutput{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
v := res.Output().(*UpdateOutput)

View File

@ -41,5 +41,5 @@ var VersionCmd = &cmds.Command{
return strings.NewReader(fmt.Sprintf("ipfs version %s\n", v.Version)), nil
},
},
Type: &VersionOutput{},
Type: VersionOutput{},
}