Skip to content

Commit 83b7a21

Browse files
authored
auto-complete case-insensitive (#270)
1 parent 2b75fd9 commit 83b7a21

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Master
44

5+
- update: auto-complete case-insensitive
6+
57
### 3.0.38
68

79
- update: meta data

openapi/commando.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ func (c *Commando) complete(ctx *cli.Context, args []string) []string {
357357
//
358358
// aliyun
359359
if len(args) == 0 {
360+
// Case insensitive strings.ToLower()
360361
ctx.Command().ExecuteComplete(ctx, args)
361362
for _, p := range c.library.GetProducts() {
362-
if !strings.HasPrefix(p.GetLowerCode(), ctx.Completion().Current) {
363+
if !strings.HasPrefix(p.GetLowerCode(), strings.ToLower(ctx.Completion().Current)) {
363364
continue
364365
}
365366
cli.PrintfWithColor(w, cli.ProductListColor(), "%s\n", p.GetLowerCode())
@@ -375,7 +376,7 @@ func (c *Commando) complete(ctx *cli.Context, args []string) []string {
375376
if product.ApiStyle == "rpc" {
376377
if len(args) == 1 {
377378
for _, name := range product.ApiNames {
378-
if !strings.HasPrefix(name, ctx.Completion().Current) {
379+
if !strings.HasPrefix(strings.ToLower(name), strings.ToLower(ctx.Completion().Current)) {
379380
continue
380381
}
381382
cli.PrintfWithColor(w, cli.APIListColor(), "%s\n", name)
@@ -388,7 +389,7 @@ func (c *Commando) complete(ctx *cli.Context, args []string) []string {
388389
}
389390

390391
api.ForeachParameters(func(s string, p meta.Parameter) {
391-
if strings.HasPrefix("--"+s, ctx.Completion().Current) && !p.Hidden {
392+
if strings.HasPrefix("--"+strings.ToLower(s), strings.ToLower(ctx.Completion().Current)) && !p.Hidden {
392393
cli.Printf(ctx.Writer(), "--%s\n", s)
393394
}
394395
})

0 commit comments

Comments
 (0)