Skip to content

Commit

Permalink
Package Shell:
Browse files Browse the repository at this point in the history
- fix info command & autocompletion

Other:
- bump dependencies
  • Loading branch information
nabbar committed Jul 28, 2023
1 parent 43dbab6 commit ec30365
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
52 changes: 27 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/nabbar/golib
go 1.20

require (
github.com/aws/aws-sdk-go-v2 v1.19.0
github.com/aws/aws-sdk-go-v2/config v1.18.28
github.com/aws/aws-sdk-go-v2/credentials v1.13.27
github.com/aws/aws-sdk-go-v2/service/iam v1.21.1
github.com/aws/aws-sdk-go-v2/service/s3 v1.37.0
github.com/aws/aws-sdk-go-v2 v1.19.1
github.com/aws/aws-sdk-go-v2/config v1.18.30
github.com/aws/aws-sdk-go-v2/credentials v1.13.29
github.com/aws/aws-sdk-go-v2/service/iam v1.21.2
github.com/aws/aws-sdk-go-v2/service/s3 v1.37.1
github.com/bits-and-blooms/bitset v1.8.0
github.com/c-bata/go-prompt v0.2.6
github.com/fatih/color v1.15.0
Expand All @@ -30,9 +30,9 @@ require (
github.com/nats-io/jwt/v2 v2.4.1
github.com/nats-io/nats-server/v2 v2.9.20
github.com/nats-io/nats.go v1.28.0
github.com/nutsdb/nutsdb v0.12.3
github.com/nutsdb/nutsdb v0.12.6
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.9
github.com/onsi/gomega v1.27.10
github.com/pelletier/go-toml v1.9.5
github.com/prometheus/client_golang v1.16.0
github.com/shirou/gopsutil v3.21.11+incompatible
Expand All @@ -45,7 +45,7 @@ require (
github.com/xanzy/go-gitlab v0.88.0
github.com/xhit/go-simple-mail v2.2.2+incompatible
github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
golang.org/x/net v0.12.0
golang.org/x/oauth2 v0.10.0
golang.org/x/sync v0.3.0
Expand All @@ -63,7 +63,7 @@ require (
require (
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/ClickHouse/ch-go v0.58.0 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.11.0 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.12.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
Expand All @@ -75,24 +75,25 @@ require (
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.27 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.6 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.36 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.30 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.37 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.28 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.30 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.31 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.30 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.14 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.14 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.20.1 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/bytedance/sonic v1.9.2 // indirect
github.com/bytedance/sonic v1.10.0-rc3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/cockroachdb/errors v1.10.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20210331181633-27fc006b8bfb // indirect
Expand All @@ -110,6 +111,7 @@ require (
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
Expand All @@ -118,7 +120,7 @@ require (
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down Expand Up @@ -149,7 +151,7 @@ require (
github.com/lni/goutils v1.3.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mattn/go-tty v0.0.5 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
Expand All @@ -170,7 +172,7 @@ require (
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
26 changes: 14 additions & 12 deletions shell/goprompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ import (
)

func (s *shell) RunPrompt(out, err io.Writer, opt ...libshl.Option) {
var (
cmp = make([]libshl.Suggest, 0)
)

_ = s.Walk(func(name string, item shlcmd.Command) (shlcmd.Command, liberr.Error) {
cmp = append(cmp, libshl.Suggest{
Text: name,
Description: item.Describe(),
})

return nil, nil
})

p := libshl.New(
func(inputLine string) {
if out == nil {
Expand All @@ -61,18 +74,7 @@ func (s *shell) RunPrompt(out, err io.Writer, opt ...libshl.Option) {
s.Run(out, err, strings.Fields(inputLine))
},
func(document libshl.Document) []libshl.Suggest {
var res = make([]libshl.Suggest, 0)

_ = s.Walk(func(name string, item shlcmd.Command) (shlcmd.Command, liberr.Error) {
res = append(res, libshl.Suggest{
Text: name,
Description: item.Describe(),
})

return nil, nil
})

return res
return libshl.FilterHasPrefix(cmp, document.GetWordBeforeCursor(), true)
},
opt...,
)
Expand Down

0 comments on commit ec30365

Please sign in to comment.