update err not found arg
All checks were successful
Go Action / goaction (pull_request) Successful in 1m29s

This commit is contained in:
2026-01-06 16:05:24 +03:00
parent 190950aca0
commit 89f664c268
2 changed files with 17 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package arg
import (
"context"
"errors"
"fmt"
"io"
"os"
@@ -217,7 +218,21 @@ func (i *Argv) parseShortOption(arg string, def config.Variables) error {
func (i *Argv) parseArgument(arg string, def config.Variables) error {
opt, err := def.ByParam(PosArgument(i.pos))
if err != nil {
return fmt.Errorf("%w", err)
var maxArgs uint64
if i.pos > 0 {
maxArgs -= i.pos
}
if errors.Is(err, config.ErrNotFound) {
return fmt.Errorf("argument[%s] by pos[%d] max[%d]: %w",
arg,
i.pos+1,
maxArgs,
config.ErrNotFound,
)
}
return fmt.Errorf("find argiment by pos[%d] max[%d]: %w", i.pos+1, maxArgs, err)
}
i.pos++

View File

@@ -34,7 +34,7 @@ func (c chain) Bind(ctx context.Context, def config.Variables) error {
for _, input := range c {
if prov, ok := input.(config.BindProvider); ok {
if err := prov.Bind(ctx, def); err != nil {
return fmt.Errorf("%T:%w", input, err)
return fmt.Errorf("prov[%s]:%w", input.Name(), err)
}
}
}