1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 18:13:54 +08:00

add string method to command details

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
Brian Tiger Chow
2014-11-13 22:47:58 -08:00
committed by Juan Batiz-Benet
parent 1348af01b9
commit 0eeed7cc68
2 changed files with 8 additions and 0 deletions

View File

@ -1,6 +1,8 @@
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 }

View File

@ -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])