in openapi/commando.go [427:482]
func (c *Commando) complete(ctx *cli.Context, args []string) []string {
w := ctx.Stdout()
r := make([]string, 0)
//
// aliyun
if len(args) == 0 {
// Case insensitive strings.ToLower()
ctx.Command().ExecuteComplete(ctx, args)
for _, p := range c.library.GetProducts() {
if !strings.HasPrefix(p.GetLowerCode(), strings.ToLower(ctx.Completion().Current)) {
continue
}
cli.PrintfWithColor(w, "", "%s\n", p.GetLowerCode())
}
return r
}
product, ok := c.library.GetProduct(args[0])
if !ok {
return r
}
if product.ApiStyle == "rpc" {
if len(args) == 1 {
for _, name := range product.ApiNames {
if !strings.HasPrefix(strings.ToLower(name), strings.ToLower(ctx.Completion().Current)) {
continue
}
cli.PrintfWithColor(w, "", "%s\n", name)
}
return r
}
api, ok := c.library.GetApi(product.Code, product.Version, args[1])
if !ok {
return r
}
api.ForeachParameters(func(s string, p meta.Parameter) {
if strings.HasPrefix("--"+strings.ToLower(s), strings.ToLower(ctx.Completion().Current)) && !p.Hidden {
cli.Printf(ctx.Stdout(), "--%s\n", s)
}
})
} else if product.ApiStyle == "restful" {
if len(args) == 1 {
cli.PrintfWithColor(w, "", "GET\n")
cli.PrintfWithColor(w, "", "POST\n")
cli.PrintfWithColor(w, "", "DELETE\n")
cli.PrintfWithColor(w, "", "PUT\n")
return r
}
}
return r
}