Add UsageError and MissingConf back

pull/85/head v0.10.0
rwxrob 2 years ago
parent de68606750
commit 2075530694
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77

@ -525,7 +525,6 @@ func (x *Cmd) Log(format string, a ...any) {
// convenience. See UseConf.
func (x *Cmd) C(q string) (string, error) {
if Conf == nil {
log.Printf("cmd %q requires a configurer (Z.Conf must be assigned)", x.Name)
return "", UsesConf{x}
}
path := x.Path()
@ -581,6 +580,11 @@ func (x *Cmd) Fill(tmpl string) string {
return buf.String()
}
// UsageError returns IncorrectUsage for self.
func (x *Cmd) UsageError() error {
return IncorrectUsage{x}
}
// --------------------- bonzai.Command interface ---------------------
// GetName fulfills the bonzai.Command interface. No Fill.

@ -26,6 +26,14 @@ func (e WrongNumArgs) Error() string {
return fmt.Sprintf("wrong number of args, %v required", e.Cmd.NumArgs)
}
type MissingConf struct {
Path string
}
func (e MissingConf) Error() string {
return fmt.Sprintf("missing conf value for %v", e.Path)
}
type UsesConf struct {
Cmd *Cmd
}

Loading…
Cancel
Save