treat \ as escape only before a separator

This commit is contained in:
David Shiflet
2022-05-03 21:19:51 -04:00
committed by Alec Thomas
parent 5538b7f045
commit 29685e7da6
5 changed files with 86 additions and 20 deletions
+26
View File
@@ -0,0 +1,26 @@
//go:build !windows
// +build !windows
package kong_test
import (
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestPathMapper(t *testing.T) {
var cli struct {
Path string `arg:"" type:"path"`
}
p := mustNew(t, &cli)
_, err := p.Parse([]string{"/an/absolute/path"})
require.NoError(t, err)
require.Equal(t, "/an/absolute/path", cli.Path)
_, err = p.Parse([]string{"-"})
require.NoError(t, err)
require.Equal(t, "-", cli.Path)
}