Clean up and remove Files (in fs now)

pull/53/head v0.0.33
rwxrob 2 years ago
parent 57126bca96
commit 2ded06ea89
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77

@ -28,7 +28,6 @@ import (
"strings"
config "github.com/rwxrob/config/pkg"
"github.com/rwxrob/fn/maps"
"github.com/rwxrob/fs/file"
"github.com/rwxrob/term"
)
@ -195,30 +194,6 @@ func ArgsOrIn(args []string) string {
return strings.Join(args, " ")
}
// Files returns a slice of strings matching the names of the files
// within the given directory adding a slash to the end of any
// directories and escaping any spaces by adding backslash. Note that
// this function assumes forward slash path separators since completion
// is only supported on operating systems where such is the case.
func Files(dir string) []string {
if dir == "" {
dir = "."
}
files := []string{}
entries, err := os.ReadDir(dir)
if err != nil {
return files
}
names := maps.MarkDirs(entries)
if dir == "." {
return names
}
if dir[len(dir)-1] != '/' {
dir += "/"
}
return maps.EscSpace(maps.Prefix(names, dir))
}
// Aliases allows Bonzai tree developers to create aliases (similar to
// shell aliases) that are directly translated into arguments to the
// Bonzai tree executable by overriding the os.Args in a controlled way.

@ -8,7 +8,6 @@ import (
"os"
"github.com/rwxrob/bonzai"
"github.com/rwxrob/fn/each"
)
func ExampleArgsFrom() {
@ -50,39 +49,3 @@ func ExampleArgsOrIn_args_Joined() {
// Output:
// some thing
}
func ExampleFiles() {
each.Println(bonzai.Files("testdata/files"))
// Output:
// testdata/files/bar
// testdata/files/blah
// testdata/files/dir1/
// testdata/files/foo
// testdata/files/other
// testdata/files/some
}
func ExampleFiles_spaces() {
each.Println(bonzai.Files("testdata/files/dir1"))
// Output:
// testdata/files/dir1/some\ thing
}
func ExampleFiles_empty() {
os.Chdir("testdata/files")
defer os.Chdir("../..")
each.Println(bonzai.Files(""))
// Output:
// bar
// blah
// dir1/
// foo
// other
// some
}
func ExampleFiles_not_Directory() {
fmt.Println(bonzai.Files("none"))
// Output:
// []
}

@ -3,9 +3,21 @@ module github.com/rwxrob/bonzai
go 1.18
require (
github.com/rwxrob/fn v0.1.0
github.com/rwxrob/config v0.3.1
github.com/rwxrob/fn v0.3.0
github.com/rwxrob/fs v0.4.2
github.com/rwxrob/json v0.4.1
github.com/rwxrob/structs v0.5.0
github.com/rwxrob/term v0.1.4
golang.org/x/mod v0.5.1
)
require github.com/rwxrob/to v0.1.1 // indirect
require (
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rwxrob/to v0.2.1 // indirect
github.com/rwxrob/y2j v0.3.1 // indirect
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

@ -1,8 +1,35 @@
github.com/rwxrob/fn v0.1.0 h1:vlQOPxZ77IlXSIDu2eIkuQgMtInlMNRHqwgKfkNAHAA=
github.com/rwxrob/fn v0.1.0/go.mod h1:omPqOqEB+dDna09z5pi5YFxq4IZqDvv3wFPUCES5LvY=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rwxrob/config v0.3.1 h1:YwnPEuEFDZz7gD5ZJwYkYEF/oSjvM9ryXV6oK+aDvJc=
github.com/rwxrob/config v0.3.1/go.mod h1:aqV/tWGH+Tz2ciADZDDYoodAniZ2iQTm8WZNM0wRyCA=
github.com/rwxrob/fn v0.3.0 h1:R4kcZhInEc9Fn3lsWbn3O6ZOoZ/D43Y1l3SS5Nxm1wc=
github.com/rwxrob/fn v0.3.0/go.mod h1:omPqOqEB+dDna09z5pi5YFxq4IZqDvv3wFPUCES5LvY=
github.com/rwxrob/fs v0.4.2 h1:KXBs48us7rwkIAT05IMpKJ2AQNHLGBqHaqaCpXjrys0=
github.com/rwxrob/fs v0.4.2/go.mod h1:vO8AeluD7rnrO7zC54745xTEBFgHPUpHL0hbp1NnsVo=
github.com/rwxrob/json v0.4.1 h1:b4ToZe4mrQO8rRL/kRFglzZszyZZnGv6JRHj6jrI3f4=
github.com/rwxrob/json v0.4.1/go.mod h1:DU3TQKCWY4bK7sQ0wu80cRmTs96b6M//OYvT7Eg2mJA=
github.com/rwxrob/to v0.1.1 h1:/nHpuP6nNn44Gl+oa50M79AxslxZiBwlNhvY2UdNphA=
github.com/rwxrob/to v0.1.1/go.mod h1:8qdgCWkh50Avs8sRpV6/P7lAQgVf3KLRSKMZahV/W48=
github.com/rwxrob/structs v0.5.0 h1:pjLsfyYHS+gB1CtzRj3H39wRYL4lI5pTpFf8kl91guw=
github.com/rwxrob/structs v0.5.0/go.mod h1:2gIte2ZI9zUok6q6F3v3l41ZXo7Zg5Kf1GUTP2+pXyQ=
github.com/rwxrob/term v0.1.4 h1:E49nmDAd7rwfjhled17RapP6RJP6T3a0NGIdW44WVAU=
github.com/rwxrob/term v0.1.4/go.mod h1:IVE7hG+VQlM4R+kS4pY6uhfMHoG0QECrZF7d7bKcdsk=
github.com/rwxrob/to v0.2.1 h1:ZYBNEa8LJT5VDQUHm2wSwiRf61xSqU87UqbYvitV3eY=
github.com/rwxrob/to v0.2.1/go.mod h1:8qdgCWkh50Avs8sRpV6/P7lAQgVf3KLRSKMZahV/W48=
github.com/rwxrob/y2j v0.3.1 h1:qOCU7J6g0Q/7KlLAabCMLx6/wG1/NelG6QTOVpESAQg=
github.com/rwxrob/y2j v0.3.1/go.mod h1:/3eS+LPnOF1F2VfoqZr3Upkr8q4ByziAi3eB6FIgzoE=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886 h1:eJv7u3ksNXoLbGSKuv2s/SIO4tJVxc/A+MTpzxDgz/Q=
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

@ -1,14 +0,0 @@
go 1.18
use (
.
../fn
../fs
../json
../config
../y2j
../scan
../structs
../term
../to
)
Loading…
Cancel
Save