@cryptotaxi247 / kubo / commits / 15f850f08

refactor(2/main) helper methods for details object

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Nov 16, 2014 at 00:36 UTC 15f850f08c408c4cb319c1c857a4a727f80235ea
3 files changed +8 -8
cmd/ipfs2/ipfs.go
+5 -4
@@ -76,10 +76,11 @@ func (d *cmdDetails) String() string {
76 d.canRunOnClient(), d.canRunOnDaemon(), d.usesRepo())
77 }
78
79 -func (d *cmdDetails) usesConfigAsInput() bool { return !d.doesNotUseConfigAsInput }
80 -func (d *cmdDetails) canRunOnClient() bool { return !d.cannotRunOnClient }
81 -func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon }
82 -func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
79 +func (d *cmdDetails) usesConfigAsInput() bool { return !d.doesNotUseConfigAsInput }
80 +func (d *cmdDetails) doesNotPreemptAutoUpdate() bool { return !d.preemptsAutoUpdate }
81 +func (d *cmdDetails) canRunOnClient() bool { return !d.cannotRunOnClient }
82 +func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon }
83 +func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
84
85 // "What is this madness!?" you ask. Our commands have the unfortunate problem of
86 // not being able to run on all the same contexts. This map describes these
cmd/ipfs2/main.go
+1 -2
@@ -219,7 +219,7 @@ func callPreCommandHooks(details cmdDetails, req cmds.Request, root *cmds.Comman
219 // check for updates when 1) commands is going to be run locally, 2) the
220 // command does not initialize the config, and 3) the command does not
221 // pre-empt updates
222 - if !daemon && details.usesConfigAsInput() && !details.preemptsAutoUpdate {
222 + if !daemon && details.usesConfigAsInput() && details.doesNotPreemptAutoUpdate() {
223
224 log.Debug("Calling hook: Check for updates")
225
@@ -328,7 +328,6 @@ func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
328 details = cmdDetails
329 }
330 }
331 - log.Debugf("cmd perms for +%v: %s", path, details.String())
331 return &details, nil
332 }
333
util/elog/metadata.go
+2 -2
@@ -16,8 +16,8 @@ type Loggable interface {
16 Loggable() map[string]interface{}
17 }
18
19 -// UniqueEvent returns a Metadata with the string key and UUID value
20 -func UniqueEvent(key string) Metadata {
19 +// Uuid returns a Metadata with the string key and UUID value
20 +func Uuid(key string) Metadata {
21 return Metadata{
22 key: uuid.New(),
23 }