@cryptotaxi247 / kubo / commits / 6236ef7fd

core/commands: Made add command output a channel

core/commands: Don't use pointers for Type field

Matt Bell committed Jan 6, 2015 at 11:36 UTC 6236ef7fdb8108ac8f635dff13eb824c330e67be
17 files changed +23 -23
core/commands/add.go
+1 -1
@@ -102,7 +102,7 @@ remains to be implemented.
102 }, nil
103 },
104 },
105 - Type: &AddedObject{},
105 + Type: AddedObject{},
106 }
107
108 func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
core/commands/block.go
+1 -1
@@ -123,7 +123,7 @@ It reads from stdin, and <key> is a base58 encoded multihash.
123 Length: len(data),
124 }, nil
125 },
126 - Type: &Block{},
126 + Type: Block{},
127 Marshalers: cmds.MarshalerMap{
128 cmds.Text: func(res cmds.Response) (io.Reader, error) {
129 block := res.Output().(*Block)
core/commands/bootstrap.go
+3 -3
@@ -112,7 +112,7 @@ in the bootstrap list).
112
113 return &BootstrapOutput{added}, nil
114 },
115 - Type: &BootstrapOutput{},
115 + Type: BootstrapOutput{},
116 Marshalers: cmds.MarshalerMap{
117 cmds.Text: func(res cmds.Response) (io.Reader, error) {
118 v, ok := res.Output().(*BootstrapOutput)
@@ -173,7 +173,7 @@ var bootstrapRemoveCmd = &cmds.Command{
173
174 return &BootstrapOutput{removed}, nil
175 },
176 - Type: &BootstrapOutput{},
176 + Type: BootstrapOutput{},
177 Marshalers: cmds.MarshalerMap{
178 cmds.Text: func(res cmds.Response) (io.Reader, error) {
179 v, ok := res.Output().(*BootstrapOutput)
@@ -203,7 +203,7 @@ var bootstrapListCmd = &cmds.Command{
203 peers := cfg.Bootstrap
204 return &BootstrapOutput{peers}, nil
205 },
206 - Type: &BootstrapOutput{},
206 + Type: BootstrapOutput{},
207 Marshalers: cmds.MarshalerMap{
208 cmds.Text: bootstrapMarshaler,
209 },
core/commands/commands.go
+1 -1
@@ -36,7 +36,7 @@ func CommandsCmd(root *cmds.Command) *cmds.Command {
36 return &buf, nil
37 },
38 },
39 - Type: &Command{},
39 + Type: Command{},
40 }
41 }
42
core/commands/config.go
+1 -1
@@ -95,7 +95,7 @@ Set the value of the 'datastore.path' key:
95 return bytes.NewReader(buf), nil
96 },
97 },
98 - Type: &ConfigField{},
98 + Type: ConfigField{},
99 Subcommands: map[string]*cmds.Command{
100 "show": configShowCmd,
101 "edit": configEditCmd,
core/commands/diag.go
+1 -1
@@ -84,7 +84,7 @@ connected peers and latencies between them.
84
85 return &DiagnosticOutput{output}, nil
86 },
87 - Type: &DiagnosticOutput{},
87 + Type: DiagnosticOutput{},
88 Marshalers: cmds.MarshalerMap{
89 cmds.Text: func(r cmds.Response) (io.Reader, error) {
90 output, ok := r.Output().(*DiagnosticOutput)
core/commands/id.go
+1 -1
@@ -91,7 +91,7 @@ if no peer is specified, prints out local peers info.
91 return bytes.NewReader(marshaled), nil
92 },
93 },
94 - Type: &IdOutput{},
94 + Type: IdOutput{},
95 }
96
97 func printPeer(ps peer.Peerstore, p peer.ID) (interface{}, error) {
core/commands/log.go
+1 -1
@@ -48,5 +48,5 @@ output of a running daemon.
48 Marshalers: cmds.MarshalerMap{
49 cmds.Text: MessageTextMarshaler,
50 },
51 - Type: &MessageOutput{},
51 + Type: MessageOutput{},
52 }
core/commands/ls.go
+1 -1
@@ -89,7 +89,7 @@ it contains, with the following format:
89 return strings.NewReader(s), nil
90 },
91 },
92 - Type: &LsOutput{},
92 + Type: LsOutput{},
93 }
94
95 func marshalLinks(links []Link) (s string) {
core/commands/mount_unix.go
+1 -1
@@ -133,7 +133,7 @@ baz
133 output.IPNS = nsdir
134 return &output, nil
135 },
136 - Type: &config.Mounts{},
136 + Type: config.Mounts{},
137 Marshalers: cmds.MarshalerMap{
138 cmds.Text: func(res cmds.Response) (io.Reader, error) {
139 v := res.Output().(*config.Mounts)
core/commands/object.go
+3 -3
@@ -108,7 +108,7 @@ multihash.
108 return strings.NewReader(marshalled), nil
109 },
110 },
111 - Type: &Object{},
111 + Type: Object{},
112 }
113
114 var objectGetCmd = &cmds.Command{
@@ -162,7 +162,7 @@ This command outputs data in the following encodings:
162
163 return node, nil
164 },
165 - Type: &Node{},
165 + Type: Node{},
166 Marshalers: cmds.MarshalerMap{
167 cmds.EncodingType("protobuf"): func(res cmds.Response) (io.Reader, error) {
168 node := res.Output().(*Node)
@@ -232,7 +232,7 @@ Data should be in the format specified by <encoding>.
232 return strings.NewReader("added " + object.Hash), nil
233 },
234 },
235 - Type: &Object{},
235 + Type: Object{},
236 }
237
238 // objectData takes a key string and writes out the raw bytes of that node (if there is one)
core/commands/pin.go
+1 -1
@@ -157,7 +157,7 @@ Use --type=<type> to specify the type of pinned keys to list. Valid values are:
157
158 return &KeyList{Keys: keys}, nil
159 },
160 - Type: &KeyList{},
160 + Type: KeyList{},
161 Marshalers: cmds.MarshalerMap{
162 cmds.Text: KeyListTextMarshaler,
163 },
core/commands/publish.go
+1 -1
@@ -86,7 +86,7 @@ Publish a <ref> to another public key:
86 return strings.NewReader(s), nil
87 },
88 },
89 - Type: &IpnsEntry{},
89 + Type: IpnsEntry{},
90 }
91
92 func publish(n *core.IpfsNode, k crypto.PrivKey, ref string) (*IpnsEntry, error) {
core/commands/refs.go
+1 -1
@@ -71,7 +71,7 @@ Note: list all refs recursively with -r.
71
72 return getRefs(n, req.Arguments(), unique, recursive)
73 },
74 - Type: &KeyList{},
74 + Type: KeyList{},
75 Marshalers: cmds.MarshalerMap{
76 cmds.Text: KeyListTextMarshaler,
77 },
core/commands/swarm.go
+2 -2
@@ -69,7 +69,7 @@ ipfs swarm peers lists the set of peers this node is connected to.
69 Marshalers: cmds.MarshalerMap{
70 cmds.Text: stringListMarshaler,
71 },
72 - Type: &stringList{},
72 + Type: stringList{},
73 }
74
75 var swarmConnectCmd = &cmds.Command{
@@ -122,7 +122,7 @@ ipfs swarm connect /ip4/104.131.131.82/tcp/4001/QmaCpDMGvV2BGHeYERUEnRQAwe3N8Szb
122 Marshalers: cmds.MarshalerMap{
123 cmds.Text: stringListMarshaler,
124 },
125 - Type: &stringList{},
125 + Type: stringList{},
126 }
127
128 func stringListMarshaler(res cmds.Response) (io.Reader, error) {
core/commands/update.go
+2 -2
@@ -29,7 +29,7 @@ var UpdateCmd = &cmds.Command{
29 }
30 return updateApply(n)
31 },
32 - Type: &UpdateOutput{},
32 + Type: UpdateOutput{},
33 Subcommands: map[string]*cmds.Command{
34 "check": UpdateCheckCmd,
35 "log": UpdateLogCmd,
@@ -62,7 +62,7 @@ var UpdateCheckCmd = &cmds.Command{
62 }
63 return updateCheck(n)
64 },
65 - Type: &UpdateOutput{},
65 + Type: UpdateOutput{},
66 Marshalers: cmds.MarshalerMap{
67 cmds.Text: func(res cmds.Response) (io.Reader, error) {
68 v := res.Output().(*UpdateOutput)
core/commands/version.go
+1 -1
@@ -41,5 +41,5 @@ var VersionCmd = &cmds.Command{
41 return strings.NewReader(fmt.Sprintf("ipfs version %s\n", v.Version)), nil
42 },
43 },
44 - Type: &VersionOutput{},
44 + Type: VersionOutput{},
45 }