Define initial Conf for everything

pull/53/head
rwxrob 2 years ago
parent 932aac7694
commit d15e25bcb2
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77

13
cache/cache.go vendored

@ -0,0 +1,13 @@
package cache
// Cacher specifies high-performance caching for Bonzai commands with
// guaranteed system-wide concurrency safety (across process
// boundaries). Safe and strong caching support is a key Bonzai design
// principle since much of what might have been put into getopt dashed
// options and keys before is now done with contextual session cache to
// preserve state between Bonzai command calls. It is not uncommon for
// a given task to span multiple command calls. This also provides
// support for operating-system independent command invocation history.
type Cacher interface {
// TODO
}

@ -5,6 +5,7 @@ package bonzai
import (
"fmt"
"log"
"os"
"strings"
@ -42,7 +43,7 @@ type Cmd struct {
Hidden []string `json:"hide,omitempty"`
Completer comp.Completer `json:"-"`
Config conf.Configurer `json:"-"`
Conf conf.Configurer `json:"-"`
// Cache cache.Cacher `json:"-"`
Root *Cmd `json:"-"`
@ -96,7 +97,7 @@ func (x *Cmd) Run() {
}
x.Root = x
x.Config = DefaultConfigurer
x.Conf = DefaultConfigurer
// seek should never fail to return something, but ...
cmd, args := x.Seek(os.Args[1:])
@ -212,6 +213,7 @@ func (x *Cmd) Seek(args []string) (*Cmd, []string) {
}
next.Caller = cur
next.Root = x
next.Conf = DefaultConfigurer
cur = next
}
return cur, args[n:]
@ -232,6 +234,15 @@ func (x *Cmd) Branch() string {
return strings.Join(callers.Items(), ".")
}
// Q is a shorter version of x.Conf.Query(x.Root.Name,x.Branch()+"."+q) for convenience.
func (x *Cmd) Q(q string) string {
log.Print(x.Conf)
return ""
//return x.Conf.Query(x.Root.Name, x.Branch()+"."+q)
}
// TODO C for Cache lookups
// ---------------------- comp.Command interface ----------------------
// mostly to overcome cyclical imports

Loading…
Cancel
Save