diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d644764..ab5bc1b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,7 +14,7 @@ jobs: os: - ubuntu-latest - macos-latest - # - windows-latest + - windows-latest steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/README.md b/README.md index 80120d3..64564a1 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ support specific behaviors: - `Complete(opt *option.T, partial string) []option.Description`, if defined, let the command override the list of suggestions offered during completion of an option or an argument. By default, the completion mechanism emulates the - default behavior of bash completion and suggests any matching local file + default behavior of bash completion and suggests matching local files. ### Completion support diff --git a/RELEASES.md b/RELEASES.md index 2083f7e..357e272 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,10 @@ +# v0.2.0 + +## Major Features + +- Resolve windows compatibility issues, update go-filetuils to v0.6.0, which + addresses the same issue. + # v0.1.0 ## Major Features diff --git a/cli.go b/cli.go index f5b6c7b..767b965 100644 --- a/cli.go +++ b/cli.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" "os" - "path/filepath" + "github.com/maargenton/go-fileutils" "golang.org/x/term" "github.com/maargenton/go-cli/pkg/cli" @@ -43,7 +43,7 @@ var FilepathCompletion = cli.FilepathCompletion // Run takes the command line arguments, parses them and execute the // command or sub-command with the corresponding options. func Run(cmd *Command) { - cmd.ProcessName = filepath.Base(os.Args[0]) + cmd.ProcessName = fileutils.Base(os.Args[0]) cmd.ProcessArgs = os.Args cmd.ConsoleWidth = consoleWidth() cmd.SetProcessEnv(os.Environ()) diff --git a/go.mod b/go.mod index b140c6e..5b217ed 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/maargenton/go-errors v1.0.0 - github.com/maargenton/go-fileutils v0.5.0 - github.com/maargenton/go-testpredicate v0.6.4 + github.com/maargenton/go-fileutils v0.6.0 + github.com/maargenton/go-testpredicate v1.0.0 golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf ) diff --git a/go.sum b/go.sum index e0f64ca..ee45045 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,13 @@ github.com/maargenton/fileutil v0.4.1/go.mod h1:+GxNHyNo3uqVv2QJPfmdzIByRSLf5qKKA6AUO+PoooY= github.com/maargenton/go-errors v0.0.0-20200720205202-f0b27f4dc001/go.mod h1:qw42L2So9gQZM8ZrnBoBc4deYTaL89dyE+2wuNGELMg= -github.com/maargenton/go-errors v0.1.0/go.mod h1:yVvhNp6mywh/FFoTYbi2WPH7oP0U9AZXtvGa8SDIxOQ= github.com/maargenton/go-errors v1.0.0 h1:gNDwTfN3VHwLog2w/BfeGlCTjwjJ6H0NeMKS+4xCNE4= github.com/maargenton/go-errors v1.0.0/go.mod h1:yVvhNp6mywh/FFoTYbi2WPH7oP0U9AZXtvGa8SDIxOQ= -github.com/maargenton/go-fileutils v0.5.0 h1:U3Xj5/WMOhUVCE+d6dFlRXtTN2Xlgr7aHkB9rTzMNEA= -github.com/maargenton/go-fileutils v0.5.0/go.mod h1:8oet63VTaAY3WJkv3Y1VPzsKssB/s4W+ivGjpx62N2w= +github.com/maargenton/go-fileutils v0.6.0 h1:9bbz5tI93nW1il4JO0/2cqQj0+MpqCJgsz+qkL2DQbk= +github.com/maargenton/go-fileutils v0.6.0/go.mod h1:ve/fUYuYom3GIQwXb83RcyvpnnQm5CxW0L3wKVf4yvA= github.com/maargenton/go-testpredicate v0.4.4/go.mod h1:sn267JpJ65uvLQ7VtYzPLvXQiw0tHHw+KbCFzxRPOww= -github.com/maargenton/go-testpredicate v0.6.4 h1:bXvVpgmCBCyG290aLruxL7fv4k8QdXVyz0WeABVqVTQ= github.com/maargenton/go-testpredicate v0.6.4/go.mod h1:lUPR99Ipl1o49oRb5wEUwb/7KXrwc1FAVR6aZmCmoS8= +github.com/maargenton/go-testpredicate v1.0.0 h1:8dimey5rt3kbqTFADidZYnbdnLfjWTyYD3vitM77q4s= +github.com/maargenton/go-testpredicate v1.0.0/go.mod h1:ZscqHa6PT35rm0psZd9y1KV6ygPL1C5NfDFBDFTkGu8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -32,6 +32,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/cli/completion.go b/pkg/cli/completion.go index 59e8d4a..9571618 100644 --- a/pkg/cli/completion.go +++ b/pkg/cli/completion.go @@ -2,12 +2,13 @@ package cli import ( "fmt" - "path/filepath" "strconv" "strings" - "github.com/maargenton/go-cli/pkg/option" + "github.com/maargenton/go-fileutils" "github.com/maargenton/go-fileutils/pkg/dir" + + "github.com/maargenton/go-cli/pkg/option" ) // BashCompletionScript returns a string containing the bash script necessary to @@ -50,7 +51,7 @@ func DefaultCompletion(w string) []option.Description { var r []option.Description files, err := dir.Glob(fmt.Sprintf("%v*", w)) if err == nil { - if len(files) == 1 && strings.HasSuffix(files[0], string(filepath.Separator)) { + if len(files) == 1 && strings.HasSuffix(files[0], string(fileutils.Separator)) { return DefaultCompletion(files[0]) } for _, f := range files { diff --git a/pkg/cli/completion_test.go b/pkg/cli/completion_test.go index 340d498..3526004 100644 --- a/pkg/cli/completion_test.go +++ b/pkg/cli/completion_test.go @@ -67,8 +67,10 @@ func TestDefaultCompletion(t *testing.T) { t.Run("when Calling DefaultCompletion() with partial unique folder name", func(t *testing.T) { suggestions := cli.DefaultCompletion("../cl") t.Run("then suggestions include the files in that folder", func(t *testing.T) { - require.That(t, suggestions).Field("Option").IsSupersetOf( - []string{"../cli/completion.go", "../cli/completion_test.go"}) + require.That(t, suggestions).Field("Option").IsSupersetOf([]string{ + "../cli/completion.go", + "../cli/completion_test.go", + }) }) }) })