add string method to command details
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 13, 2014 at 22:47 UTC
0eeed7cc68caafc8cede3168e7c10fd20b73c315
2 files changed
+8
cmd/ipfs2/ipfs.go
+7
@@ -1,6 +1,8 @@
1
package main
2
3
import (
4
+ "fmt"
5
+
6
cmds "github.com/jbenet/go-ipfs/commands"
7
commands "github.com/jbenet/go-ipfs/core/commands2"
8
)
@@ -55,6 +57,11 @@ type cmdDetails struct {
57
doesNotUseRepo bool
58
}
59
60
+func (d *cmdDetails) String() string {
61
+ return fmt.Sprintf("on client? %t, on daemon? %t, uses repo? %t",
62
+ d.canRunOnClient(), d.canRunOnDaemon(), d.usesRepo())
63
+}
64
+
65
func (d *cmdDetails) canRunOnClient() bool { return !d.cannotRunOnClient }
66
func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon }
67
func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
cmd/ipfs2/main.go
+1
@@ -276,6 +276,7 @@ func commandShouldRunOnDaemon(req cmds.Request, root *cmds.Command) (bool, error
276
if !found {
277
details = cmdDetails{} // defaults
278
}
279
+ log.Debugf("cmd perms for +%v: %s", path, details.String())
280
281
if details.cannotRunOnClient && details.cannotRunOnDaemon {
282
return false, fmt.Errorf("command disabled: %s", path[0])