Drop automatic message prefix from command errors (#384)

This commit is contained in:
Jan Heuermann
2023-10-07 09:15:33 +02:00
committed by GitHub
parent 46c03841ed
commit 93d31e17f4
5 changed files with 24 additions and 15 deletions
+17
View File
@@ -641,6 +641,23 @@ func TestRun(t *testing.T) {
assert.Equal(t, "argping", cli.Three.SubCommand.Arg)
}
type failCmd struct{}
func (f failCmd) Run() error {
return errors.New("this command failed")
}
func TestPassesThroughOriginalCommandError(t *testing.T) {
var cli struct {
Fail failCmd `kong:"cmd"`
}
p := mustNew(t, &cli)
ctx, _ := p.Parse([]string{"fail"})
err := ctx.Run()
assert.Error(t, err)
assert.Equal(t, err.Error(), "this command failed")
}
func TestInterpolationIntoModel(t *testing.T) {
var cli struct {
Flag string `default:"${default_value}" help:"Help, I need ${somebody}" enum:"${enum}"`