diff --git a/z/cmd.go b/z/cmd.go index 202f217..2634020 100644 --- a/z/cmd.go +++ b/z/cmd.go @@ -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. diff --git a/z/errors.go b/z/errors.go index 8d93a86..b233615 100644 --- a/z/errors.go +++ b/z/errors.go @@ -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 }