mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 01:08:47 +02:00
refactor(rules): introduce block DSL, phase-based execution, and flow validation
- add block syntax parser/scanner with nested @blocks and elif/else support - restructure rule execution into explicit pre/post phases with phase flags - classify commands by phase and termination behavior - enforce flow semantics (default rule handling, dead-rule detection) - expand HTTP flow coverage with block + YAML parity tests and benches - refresh rules README/spec and update playground/docs integration
This commit is contained in:
@@ -131,12 +131,13 @@ Error generates help string as error, e.g.
|
||||
from: the path to rewrite, must start with /
|
||||
to: the path to rewrite to, must start with /
|
||||
*/
|
||||
func (h *Help) Error() error {
|
||||
var lines gperr.MultilineError
|
||||
func (h *Help) Error() gperr.Error {
|
||||
help := gperr.New(ansi.WithANSI(h.command, ansi.HighlightGreen))
|
||||
for _, line := range h.description {
|
||||
help = help.Withf("%s", line)
|
||||
}
|
||||
|
||||
lines.Adds(ansi.WithANSI(h.command, ansi.HighlightGreen))
|
||||
lines.AddStrings(h.description...)
|
||||
lines.Adds(" args:")
|
||||
args := gperr.New("args")
|
||||
|
||||
argKeys := make([]string, 0, len(h.args))
|
||||
longestArg := 0
|
||||
@@ -151,7 +152,9 @@ func (h *Help) Error() error {
|
||||
slices.Sort(argKeys)
|
||||
for _, arg := range argKeys {
|
||||
desc := h.args[arg]
|
||||
lines.Addf(" %-"+strconv.Itoa(longestArg)+"s: %s", ansi.WithANSI(arg, ansi.HighlightCyan), desc)
|
||||
paddedArg := fmt.Sprintf("%-"+strconv.Itoa(longestArg)+"s", arg)
|
||||
args = args.Withf("%s%s", ansi.WithANSI(paddedArg, ansi.HighlightCyan)+": ", desc)
|
||||
}
|
||||
return &lines
|
||||
|
||||
return help.With(args)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user