Skip to content

Commit

Permalink
Use %q instead %v to print slice (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanyu66 authored Jan 19, 2023
1 parent df42ec1 commit 73c713c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/cli/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command {

createCmd.Flags().String(flag.ClusterName, "", "Name of the cluster to de created")
createCmd.Flags().String(flag.ClusterType, "", "Cluster type, only support \"SERVERLESS\" now")
createCmd.Flags().String(flag.CloudProvider, "", "Cloud provider, one of [AWS]")
createCmd.Flags().String(flag.CloudProvider, "", "Cloud provider, one of [\"AWS\"]")
createCmd.Flags().StringP(flag.Region, flag.RegionShort, "", "Cloud region")
createCmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "The ID of the project, in which the cluster will be created")
createCmd.Flags().String(flag.RootPassword, "", "The root password of the cluster")
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/cluster/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ func ListCmd(h *internal.Helper) *cobra.Command {
},
}

listCmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, "Output format, One of: human, json, for the complete result, please use json format")
listCmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, "Output format, One of[\"human\", \"json\"], for the complete result, please use json format")
return listCmd
}
2 changes: 1 addition & 1 deletion internal/cli/dataimport/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func ListCmd(h *internal.Helper) *cobra.Command {

listCmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "Project ID")
listCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "Cluster ID")
listCmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, "Output format. One of: human, json. For the complete result, please use json format.")
listCmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, "Output format. One of[\"human\", \"json\"]. For the complete result, please use json format.")
return listCmd
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cli/dataimport/start/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func LocalCmd(h *internal.Helper) *cobra.Command {
clusterID = cmd.Flag(flag.ClusterID).Value.String()
dataFormat = cmd.Flag(flag.DataFormat).Value.String()
if !util.ElemInSlice(opts.SupportedDataFormats(), dataFormat) {
return fmt.Errorf("data format %s is not supported, please use one of %v", dataFormat, opts.SupportedDataFormats())
return fmt.Errorf("data format %s is not supported, please use one of %q", dataFormat, opts.SupportedDataFormats())
}
targetDatabase = cmd.Flag(flag.TargetDatabase).Value.String()
targetTable = cmd.Flag(flag.TargetTable).Value.String()
Expand Down Expand Up @@ -281,7 +281,7 @@ func LocalCmd(h *internal.Helper) *cobra.Command {

localCmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "Project ID")
localCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "Cluster ID")
localCmd.Flags().String(flag.DataFormat, "", fmt.Sprintf("Data format, one of %v", opts.SupportedDataFormats()))
localCmd.Flags().String(flag.DataFormat, "", fmt.Sprintf("Data format, one of %q", opts.SupportedDataFormats()))
localCmd.Flags().String(flag.TargetDatabase, "", "Target database to which import data")
localCmd.Flags().String(flag.TargetTable, "", "Target table to which import data")
return localCmd
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/dataimport/start/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (suite *LocalImportSuite) TestLocalImportArgs() {
{
name: "start import with unsupported data format",
args: []string{fileName, "--project-id", projectID, "--cluster-id", clusterID, "--data-format", "yaml", "--target-database", targetDatabase, "--target-table", targetTable},
err: fmt.Errorf("data format yaml is not supported, please use one of [CSV]"),
err: fmt.Errorf("data format yaml is not supported, please use one of [\"CSV\"]"),
},
{
name: "start import with shorthand flag",
Expand All @@ -153,7 +153,7 @@ func (suite *LocalImportSuite) TestLocalImportArgs() {
{
name: "start import without required file path",
args: []string{"-p", projectID, "-c", clusterID, "--data-format", dataFormat, "--target-database", targetDatabase, "--target-table", targetTable},
err: fmt.Errorf("missing argument <file-path> \n\nUsage:\n start local <file-path> [flags]\n\nExamples:\n Start an import task in interactive mode:\n $ ticloud import start local <file-path>\n\n Start an import task in non-interactive mode:\n $ ticloud import start local <file-path> --project-id <project-id> --cluster-id <cluster-id> --data-format <data-format> --target-database <target-database> --target-table <target-table>\n\t\n Start an import task with custom CSV format:\n $ ticloud import start local <file-path> --project-id <project-id> --cluster-id <cluster-id> --data-format CSV --target-database <target-database> --target-table <target-table> --separator \\\" --delimiter \\' --backslash-escape=false --trim-last-separator=true\n\n\nFlags:\n -c, --cluster-id string Cluster ID\n --data-format string Data format, one of [CSV]\n -h, --help help for local\n -p, --project-id string Project ID\n --target-database string Target database to which import data\n --target-table string Target table to which import data\n\nGlobal Flags:\n --backslash-escape In CSV file whether to parse backslash inside fields as escape characters (default true)\n --delimiter string The delimiter used for quoting of CSV file (default \"\\\"\")\n --separator string The field separator of CSV file (default \",\")\n --trim-last-separator In CSV file whether to treat Separator as the line terminator and trim all trailing separators\n"),
err: fmt.Errorf("missing argument <file-path> \n\nUsage:\n start local <file-path> [flags]\n\nExamples:\n Start an import task in interactive mode:\n $ ticloud import start local <file-path>\n\n Start an import task in non-interactive mode:\n $ ticloud import start local <file-path> --project-id <project-id> --cluster-id <cluster-id> --data-format <data-format> --target-database <target-database> --target-table <target-table>\n\t\n Start an import task with custom CSV format:\n $ ticloud import start local <file-path> --project-id <project-id> --cluster-id <cluster-id> --data-format CSV --target-database <target-database> --target-table <target-table> --separator \\\" --delimiter \\' --backslash-escape=false --trim-last-separator=true\n\n\nFlags:\n -c, --cluster-id string Cluster ID\n --data-format string Data format, one of [\"CSV\"]\n -h, --help help for local\n -p, --project-id string Project ID\n --target-database string Target database to which import data\n --target-table string Target table to which import data\n\nGlobal Flags:\n --backslash-escape In CSV file whether to parse backslash inside fields as escape characters (default true)\n --delimiter string The delimiter used for quoting of CSV file (default \"\\\"\")\n --separator string The field separator of CSV file (default \",\")\n --trim-last-separator In CSV file whether to treat Separator as the line terminator and trim all trailing separators\n"),
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cli/dataimport/start/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func S3Cmd(h *internal.Helper) *cobra.Command {
awsRoleArn = cmd.Flag(flag.AwsRoleArn).Value.String()
dataFormat = cmd.Flag(flag.DataFormat).Value.String()
if !util.ElemInSlice(opts.SupportedDataFormats(), dataFormat) {
return fmt.Errorf("data format %s is not supported, please use one of %v", dataFormat, opts.SupportedDataFormats())
return fmt.Errorf("data format %s is not supported, please use one of %q", dataFormat, opts.SupportedDataFormats())
}
sourceUrl = cmd.Flag(flag.SourceUrl).Value.String()

Expand Down Expand Up @@ -248,7 +248,7 @@ func S3Cmd(h *internal.Helper) *cobra.Command {
s3Cmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "Project ID")
s3Cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "Cluster ID")
s3Cmd.Flags().String(flag.AwsRoleArn, "", "AWS S3 IAM Role ARN")
s3Cmd.Flags().String(flag.DataFormat, "", fmt.Sprintf("Data format, one of %v", opts.SupportedDataFormats()))
s3Cmd.Flags().String(flag.DataFormat, "", fmt.Sprintf("Data format, one of %q", opts.SupportedDataFormats()))
s3Cmd.Flags().String(flag.SourceUrl, "", "The S3 path where the source data file is stored")
return s3Cmd
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/dataimport/start/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (suite *S3ImportSuite) TestS3ImportArgs() {
{
name: "start import with unsupported data format",
args: []string{"--project-id", projectID, "--cluster-id", clusterID, "--aws-role-arn", awsRoleArn, "--data-format", "yaml", "--source-url", sourceUrl},
err: fmt.Errorf("data format yaml is not supported, please use one of [CSV SqlFile Parquet AuroraSnapshot]"),
err: fmt.Errorf("data format yaml is not supported, please use one of [\"CSV\" \"SqlFile\" \"Parquet\" \"AuroraSnapshot\"]"),
},
{
name: "start import with shorthand flag",
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/project/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ func ListCmd(h *internal.Helper) *cobra.Command {
},
}

listCmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, "Output format. One of: json|human. For the complete result, please use json format.")
listCmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, "Output format. One of[\"human\", \"json\"]. For the complete result, please use json format.")
return listCmd
}

0 comments on commit 73c713c

Please sign in to comment.