提交 0eeed7cc 作者: Brian Tiger Chow 提交者: Juan Batiz-Benet

add string method to command details

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 1348af01
package main package main
import ( import (
"fmt"
cmds "github.com/jbenet/go-ipfs/commands" cmds "github.com/jbenet/go-ipfs/commands"
commands "github.com/jbenet/go-ipfs/core/commands2" commands "github.com/jbenet/go-ipfs/core/commands2"
) )
...@@ -55,6 +57,11 @@ type cmdDetails struct { ...@@ -55,6 +57,11 @@ type cmdDetails struct {
doesNotUseRepo bool 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) canRunOnClient() bool { return !d.cannotRunOnClient }
func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon } func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon }
func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo } func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
......
...@@ -276,6 +276,7 @@ func commandShouldRunOnDaemon(req cmds.Request, root *cmds.Command) (bool, error ...@@ -276,6 +276,7 @@ func commandShouldRunOnDaemon(req cmds.Request, root *cmds.Command) (bool, error
if !found { if !found {
details = cmdDetails{} // defaults details = cmdDetails{} // defaults
} }
log.Debugf("cmd perms for +%v: %s", path, details.String())
if details.cannotRunOnClient && details.cannotRunOnDaemon { if details.cannotRunOnClient && details.cannotRunOnDaemon {
return false, fmt.Errorf("command disabled: %s", path[0]) return false, fmt.Errorf("command disabled: %s", path[0])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论