Skip to content

Commit

Permalink
Resolve windows compatibility issues (#1)
Browse files Browse the repository at this point in the history
- Re-enable windows build target
- Update dependencies to go-fileutils v0.6.0, for windows compatibility
- Remove direct dependencies on "path/filepath"; use go-fileutils instread
- Update README and release notes for v0.2.0
  • Loading branch information
maargenton authored Sep 13, 2021
1 parent 10c0ee6 commit 5a0fd1a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
- windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand All @@ -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=
7 changes: 4 additions & 3 deletions pkg/cli/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/cli/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
})
})
})
Expand Down

0 comments on commit 5a0fd1a

Please sign in to comment.