Skip to content

Commit 77bf5f3

Browse files
authored
Merge pull request #2 from essentialkaos/develop
Version 0.0.2
2 parents 6b09b3d + 3505733 commit 77bf5f3

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ module github.com/essentialkaos/rds-cli-completion-generator
33
go 1.22.8
44

55
require github.com/essentialkaos/ek/v13 v13.15.9
6+
7+
require golang.org/x/sys v0.29.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
88
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
99
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
1010
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
11+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
12+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

rds-cli-completion-generator.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"os"
1313
"sort"
14+
"strconv"
1415
"strings"
1516

1617
"github.com/essentialkaos/ek/v13/fmtc"
@@ -34,7 +35,7 @@ import (
3435
// Basic utility info
3536
const (
3637
APP = "rds-cli-completion-generator"
37-
VER = "0.0.1"
38+
VER = "0.0.2"
3839
DESC = "Tool to generate completion for RDS CLI"
3940
)
4041

@@ -220,10 +221,10 @@ func printCommandsCode(commands InfoSlice) {
220221
fmtc.NewLine()
221222
for _, c := range commands {
222223
if len(c.Arguments) == 0 {
223-
fmtc.Printfn(` { {y}"%s"{!}, nil },`, c.Name)
224+
fmtc.Printfn(` { {y}"%s"{!}, {*}nil{!}, {*}false{!} },`, c.Name)
224225
} else {
225226
fmtc.Printfn(
226-
" { {y}\"%s\"{!}, {*}[]string{!}{"+formatArgumentsSlice(c.Arguments)+"} },",
227+
" { {y}\"%s\"{!}, {*}[]string{!}{"+formatArgumentsSlice(c.Arguments)+"}, {*}false{!} },",
227228
c.Name,
228229
)
229230
}
@@ -236,7 +237,7 @@ func formatArgumentsSlice(args []string) string {
236237
var result []string
237238

238239
for _, a := range args {
239-
result = append(result, fmt.Sprintf("{y}\"%s\"{!}", a))
240+
result = append(result, fmt.Sprintf("{y}%s{!}", strconv.Quote(a)))
240241
}
241242

242243
return strings.Join(result, ", ")

0 commit comments

Comments
 (0)