Commit 0eeed7cc authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

add string method to command details

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 1348af01
package main
import (
"fmt"
cmds "github.com/jbenet/go-ipfs/commands"
commands "github.com/jbenet/go-ipfs/core/commands2"
)
......@@ -55,6 +57,11 @@ type cmdDetails struct {
doesNotUseRepo bool
}
func (d *cmdDetails) String() string {
return fmt.Sprintf("on client? %t, on daemon? %t, uses repo? %t",
d.canRunOnClient(), d.canRunOnDaemon(), d.usesRepo())
}
func (d *cmdDetails) canRunOnClient() bool { return !d.cannotRunOnClient }
func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon }
func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
......
......@@ -276,6 +276,7 @@ func commandShouldRunOnDaemon(req cmds.Request, root *cmds.Command) (bool, error
if !found {
details = cmdDetails{} // defaults
}
log.Debugf("cmd perms for +%v: %s", path, details.String())
if details.cannotRunOnClient && details.cannotRunOnDaemon {
return false, fmt.Errorf("command disabled: %s", path[0])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment