mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 04:37:30 +08:00
add string method to command details
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:

committed by
Juan Batiz-Benet

parent
1348af01b9
commit
0eeed7cc68
@ -1,6 +1,8 @@
|
|||||||
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 {
|
|||||||
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
|
|||||||
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])
|
||||||
|
Reference in New Issue
Block a user