Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: remove unused methods #875

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -83,8 +83,8 @@ func (c *Completion) GetArgs() []string {
func parseLineForCompletion(line string, point int) []string {
if point > len(line) {
panic(fmt.Errorf("%s[%d] out of range", line, point))

}

var quote rune
var backslash bool
var word []rune
Expand Down
2 changes: 0 additions & 2 deletions cli/levenshtein_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//
// Copyright (c) 2013 Kilian Evang and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -20,7 +19,6 @@
// THE SOFTWARE.
//
// https://github.com/texttheater/golang-levenshtein
//
package cli

import (
Expand Down
8 changes: 2 additions & 6 deletions cli/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -157,7 +157,7 @@ func (p *Parser) parseCommandArg(s string) (flag *Flag, value string, err error)
return
}

//SplitStringWithPrefix TODO can use function string.SplitN to replace
// SplitStringWithPrefix TODO can use function string.SplitN to replace
func SplitStringWithPrefix(s string, splitters string) (string, string, bool) {
i := strings.IndexAny(s, splitters)
if i < 0 {
Expand All @@ -167,10 +167,6 @@ func SplitStringWithPrefix(s string, splitters string) (string, string, bool) {

}

func SplitString(s string, sep string) []string {
return strings.Split(s, sep)
}

func UnquoteString(s string) string {
if strings.HasPrefix(s, "\"") && strings.HasSuffix(s, "\"") && len(s) >= 2 {
return s[1 : len(s)-1]
Expand Down
5 changes: 0 additions & 5 deletions cli/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ var _ = ginkgo.Describe("Parser", func() {
})
})

func TestSpliString(t *testing.T) {
sli := SplitString("nihao-Mrx", "-")
assert.Len(t, sli, 2)
}

func TestUnquoteString(t *testing.T) {
str := UnquoteString(`"nicai"`)
assert.Equal(t, "nicai", str)
Expand Down
53 changes: 32 additions & 21 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -164,7 +164,8 @@ func NewProfileFlag() *cli.Flag {
Persistent: true,
Short: i18n.T(
"use `--profile <profileName>` to select profile",
"使用 `--profile <profileName>` 指定操作的配置集")}
"使用 `--profile <profileName>` 指定操作的配置集"),
}
}

func NewModeFlag() *cli.Flag {
Expand All @@ -175,7 +176,8 @@ func NewModeFlag() *cli.Flag {
Persistent: true,
Short: i18n.T(
"use `--mode {AK|StsToken|RamRoleArn|EcsRamRole|RsaKeyPair|RamRoleArnWithRoleName}` to assign authenticate mode",
"使用 `--mode {AK|StsToken|RamRoleArn|EcsRamRole|RsaKeyPair|RamRoleArnWithRoleName}` 指定认证方式")}
"使用 `--mode {AK|StsToken|RamRoleArn|EcsRamRole|RsaKeyPair|RamRoleArnWithRoleName}` 指定认证方式"),
}
}

func NewAccessKeyIdFlag() *cli.Flag {
Expand All @@ -185,7 +187,8 @@ func NewAccessKeyIdFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--access-key-id <AccessKeyId>` to assign AccessKeyId, required in AK/StsToken/RamRoleArn mode",
"使用 `--access-key-id <AccessKeyId>` 指定AccessKeyId")}
"使用 `--access-key-id <AccessKeyId>` 指定AccessKeyId"),
}
}

func NewAccessKeySecretFlag() *cli.Flag {
Expand All @@ -195,7 +198,8 @@ func NewAccessKeySecretFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--access-key-secret <AccessKeySecret>` to assign AccessKeySecret",
"使用 `--access-key-secret <AccessKeySecret>` 指定AccessKeySecret")}
"使用 `--access-key-secret <AccessKeySecret>` 指定AccessKeySecret"),
}
}

func NewStsTokenFlag() *cli.Flag {
Expand All @@ -205,7 +209,8 @@ func NewStsTokenFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--sts-token <StsToken>` to assign StsToken",
"使用 `--sts-token <StsToken>` 指定StsToken")}
"使用 `--sts-token <StsToken>` 指定StsToken"),
}
}

func NewStsRegionFlag() *cli.Flag {
Expand All @@ -215,7 +220,8 @@ func NewStsRegionFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--sts-region <StsRegion>` to assign StsRegion",
"使用 `--sts-region <StsRegion>` 指定StsRegion")}
"使用 `--sts-region <StsRegion>` 指定StsRegion"),
}
}

func NewRamRoleNameFlag() *cli.Flag {
Expand All @@ -226,7 +232,8 @@ func NewRamRoleNameFlag() *cli.Flag {
Persistent: true,
Short: i18n.T(
"use `--ram-role-name <RamRoleName>` to assign RamRoleName",
"使用 `--ram-role-name <RamRoleName>` 指定RamRoleName")}
"使用 `--ram-role-name <RamRoleName>` 指定RamRoleName"),
}
}

func NewRamRoleArnFlag() *cli.Flag {
Expand All @@ -236,7 +243,8 @@ func NewRamRoleArnFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--ram-role-arn <RamRoleArn>` to assign RamRoleArn",
"使用 `--ram-role-arn <RamRoleArn>` 指定RamRoleArn")}
"使用 `--ram-role-arn <RamRoleArn>` 指定RamRoleArn"),
}
}

func NewRoleSessionNameFlag() *cli.Flag {
Expand All @@ -246,7 +254,8 @@ func NewRoleSessionNameFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--role-session-name <RoleSessionName>` to assign RoleSessionName",
"使用 `--role-session-name <RoleSessionName>` 指定RoleSessionName")}
"使用 `--role-session-name <RoleSessionName>` 指定RoleSessionName"),
}
}
func NewExpiredSecondsFlag() *cli.Flag {
return &cli.Flag{
Expand All @@ -255,7 +264,8 @@ func NewExpiredSecondsFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--expired-seconds <seconds>` to specify expiration time",
"使用 `--expired-seconds <seconds>` 指定凭证过期时间")}
"使用 `--expired-seconds <seconds>` 指定凭证过期时间"),
}
}
func NewPrivateKeyFlag() *cli.Flag {
return &cli.Flag{
Expand All @@ -264,7 +274,8 @@ func NewPrivateKeyFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--private-key <PrivateKey>` to assign RSA PrivateKey",
"使用 `--private-key <PrivateKey>` 指定RSA私钥")}
"使用 `--private-key <PrivateKey>` 指定RSA私钥"),
}
}

func NewKeyPairNameFlag() *cli.Flag {
Expand All @@ -274,7 +285,8 @@ func NewKeyPairNameFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--key-pair-name <KeyPairName>` to assign KeyPairName",
"使用 `--key-pair-name <KeyPairName>` 指定KeyPairName")}
"使用 `--key-pair-name <KeyPairName>` 指定KeyPairName"),
}
}

func NewProcessCommandFlag() *cli.Flag {
Expand All @@ -284,8 +296,7 @@ func NewProcessCommandFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--process-command <ProcessCommand>` to specify external program execution command",
"使用 `--process-command <ProcessCommand>` 指定外部程序运行命令",
),
"使用 `--process-command <ProcessCommand>` 指定外部程序运行命令"),
}
}

Expand All @@ -296,7 +307,8 @@ func NewRegionFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--region <regionId>` to assign region",
"使用 `--region <regionId>` 来指定访问大区")}
"使用 `--region <regionId>` 来指定访问大区"),
}
}

func NewRegionIdFlag() *cli.Flag {
Expand All @@ -315,7 +327,8 @@ func NewLanguageFlag() *cli.Flag {
AssignedMode: cli.AssignedOnce,
Short: i18n.T(
"use `--language [en|zh]` to assign language",
"使用 `--language [en|zh]` 来指定语言")}
"使用 `--language [en|zh]` 来指定语言"),
}
}
func NewConfigurePathFlag() *cli.Flag {
return &cli.Flag{
Expand All @@ -325,8 +338,7 @@ func NewConfigurePathFlag() *cli.Flag {
Persistent: true,
Short: i18n.T(
"use `--config-path` to specify the configuration file path",
"使用 `--config-path` 指定配置文件路径",
),
"使用 `--config-path` 指定配置文件路径"),
}
}
func NewReadTimeoutFlag() *cli.Flag {
Expand Down Expand Up @@ -371,7 +383,6 @@ func NewSkipSecureVerify() *cli.Flag {
Persistent: true,
Short: i18n.T(
"use `--skip-secure-verify` to skip https certification validate [Not recommended]",
"使用 `--skip-secure-verify` 跳过https的证书校验 [不推荐使用]",
),
"使用 `--skip-secure-verify` 跳过https的证书校验 [不推荐使用]"),
}
}
21 changes: 0 additions & 21 deletions openapi/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,7 @@ func (a *Library) PrintProductUsage(productCode string, withApi bool) error {
} else {
cli.PrintfWithColor(a.writer, cli.Green, " %s\n", apiName)
}

}
// TODO some ApiName is too long, two column not seems good
//w := tabwriter.NewWriter(cli.GetOutputWriter(), 8, 0, 1, ' ', 0)
//for i := 0; i < len(product.ApiNames); i += 2 {
// name1 := product.ApiNames[i]
// name2 := ""
// if i + 1 < len(product.ApiNames) {
// name2 = product.ApiNames[i + 1]
// }
// fmt.Fprintf(w, " %s\t%s\n", name1, name2)
//}
//w.Flush()
}

cli.Printf(a.writer, "\nRun `aliyun %s <ApiName> --help` to get more information about this API\n", product.GetLowerCode())
Expand Down Expand Up @@ -203,12 +191,3 @@ func getDescription(d map[string]string) string {
// return ""
//}
}

//
//func (a *Helper) printCompactList() {
// for _, s := range compactList {
// product, _ := c.products.GetProduct(s)
// c.PrintProduct(product)
// }
// cli.Printf(" ... ")
//}
7 changes: 1 addition & 6 deletions openapi/response_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -39,11 +39,6 @@ func detectArrayPath(d interface{}) string {
return ""
}

//
func mergeWith(to interface{}, from interface{}) interface{} {
return nil
}

func evaluateExpr(body []byte, expr string) (string, error) {
var entity interface{}
err := json.Unmarshal(body, &entity)
Expand Down
7 changes: 1 addition & 6 deletions openapi/response_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -19,11 +19,6 @@ import (
"testing"
)

func TestMergeWith(t *testing.T) {
inter := mergeWith(nil, nil)
assert.Nil(t, inter)
}

func TestDetectArrayPath(t *testing.T) {
str := detectArrayPath("test")
assert.Equal(t, "", str)
Expand Down
Loading