Skip to content

Commit e55bc99

Browse files
Standardize Output Format for Default Values (#258)
Co-authored-by: Xiang Zhang <[email protected]>
1 parent bfdd1d7 commit e55bc99

6 files changed

Lines changed: 24 additions & 12 deletions

File tree

docs/generate_doc/ticloud_serverless_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ticloud serverless create [flags]
2626
-n, --display-name string Display name of the cluster to de created.
2727
--encryption Whether Enhanced Encryption at Rest is enabled.
2828
-h, --help help for create
29-
-p, --project-id string The ID of the project, in which the cluster will be created. (default: "default project")
29+
-p, --project-id string The ID of the project, in which the cluster will be created. (default "default project")
3030
-r, --region string The name of cloud region. You can use "ticloud serverless region" to see all regions.
3131
--spending-limit-monthly int32 Maximum monthly spending limit in USD cents. (optional)
3232
```

docs/generate_doc/ticloud_serverless_export_create.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ ticloud serverless export create [flags]
3535
--azblob.uri string The Azure Blob URI in azure://<account>.blob.core.windows.net/<container>/<path> format. Required when target type is AZURE_BLOB.
3636
-c, --cluster-id string The ID of the cluster, in which the export will be created.
3737
--compression string The compression algorithm of the export file. One of ["GZIP" "SNAPPY" "ZSTD" "NONE"].
38-
--csv.delimiter string Delimiter of string type variables in CSV files. (default "\"")
39-
--csv.null-value string Representation of null values in CSV files. (default "\\N")
38+
--csv.delimiter string Delimiter of string type variables in CSV files. (default """)
39+
--csv.null-value string Representation of null values in CSV files. (default "\N")
4040
--csv.separator string Separator of each value in CSV files. (default ",")
4141
--csv.skip-header Export CSV files of the tables without header.
42-
--display-name string The display name of the export. (default: SNAPSHOT_<snapshot_time>)
42+
--display-name string The display name of the export. (default "SNAPSHOT_<snapshot_time>")
4343
--file-type string The export file type. One of ["SQL" "CSV" "PARQUET"]. (default "CSV")
4444
--filter strings Specify the exported table(s) with table filter patterns. See https://docs.pingcap.com/tidb/stable/table-filter to learn table filter.
4545
--force Create without confirmation. You need to confirm when you want to export the whole cluster in non-interactive mode.

docs/generate_doc/ticloud_serverless_import_start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ ticloud serverless import start [flags]
3939
--azblob.uri string The Azure Blob URI in azure://<account>.blob.core.windows.net/<container>/<path> format.
4040
-c, --cluster-id string Cluster ID.
4141
--csv.backslash-escape Specifies whether to interpret backslash escapes inside fields in the CSV file. (default true)
42-
--csv.delimiter string The delimiter used for quoting of CSV file. (default "\"")
42+
--csv.delimiter string The delimiter used for quoting of CSV file. (default """)
4343
--csv.not-null Specifies whether a CSV file can contain any NULL values.
44-
--csv.null-value string The representation of NULL values in the CSV file. (default "\\N")
44+
--csv.null-value string The representation of NULL values in the CSV file. (default "\N")
4545
--csv.separator string The field separator of CSV file. (default ",")
4646
--csv.skip-header Specifies whether the CSV file contains a header line.
4747
--csv.trim-last-separator Specifies whether to treat separator as the line terminator and trim all trailing separators in the CSV file.

internal/cli/serverless/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
304304

305305
createCmd.Flags().StringP(flag.DisplayName, flag.DisplayNameShort, "", "Display name of the cluster to de created.")
306306
createCmd.Flags().StringP(flag.Region, flag.RegionShort, "", "The name of cloud region. You can use \"ticloud serverless region\" to see all regions.")
307-
createCmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "The ID of the project, in which the cluster will be created. (default: \"default project\")")
307+
createCmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "The ID of the project, in which the cluster will be created. (default \"default project\")")
308308
createCmd.Flags().Int32(flag.SpendingLimitMonthly, 0, "Maximum monthly spending limit in USD cents. (optional)")
309309
createCmd.Flags().Bool(flag.Encryption, false, "Whether Enhanced Encryption at Rest is enabled.")
310310
createCmd.Flags().Bool(flag.PublicEndpointDisabled, false, "Whether the public endpoint is disabled.")

internal/cli/serverless/dataimport/start/start.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ func StartCmd(h *internal.Helper) *cobra.Command {
255255
startCmd.Flags().String(flag.AzureBlobURI, "", "The Azure Blob URI in azure://<account>.blob.core.windows.net/<container>/<path> format.")
256256
startCmd.Flags().String(flag.AzureBlobSASToken, "", "The SAS token of Azure Blob.")
257257

258-
startCmd.Flags().String(flag.CSVDelimiter, defaultCsvDelimiter, "The delimiter used for quoting of CSV file.")
258+
startCmd.Flags().String(flag.CSVDelimiter, "", "The delimiter used for quoting of CSV file. (default \"\"\")")
259259
startCmd.Flags().String(flag.CSVSeparator, defaultCsvSeparator, "The field separator of CSV file.")
260260
startCmd.Flags().Bool(flag.CSVTrimLastSeparator, defaultCsvTrimLastSeparator, "Specifies whether to treat separator as the line terminator and trim all trailing separators in the CSV file.")
261261
startCmd.Flags().Bool(flag.CSVBackslashEscape, defaultCsvBackslashEscape, "Specifies whether to interpret backslash escapes inside fields in the CSV file.")
262262
startCmd.Flags().Bool(flag.CSVNotNull, defaultCsvNotNull, "Specifies whether a CSV file can contain any NULL values.")
263-
startCmd.Flags().String(flag.CSVNullValue, defaultCsvNullValue, "The representation of NULL values in the CSV file.")
263+
startCmd.Flags().String(flag.CSVNullValue, "", "The representation of NULL values in the CSV file. (default \"\\N\")")
264264
startCmd.Flags().Bool(flag.CSVSkipHeader, defaultCsvSkipHeader, "Specifies whether the CSV file contains a header line.")
265265
return startCmd
266266
}
@@ -456,6 +456,9 @@ func getCSVFlagValue(cmd *cobra.Command) (*imp.CSVFormat, error) {
456456
if err != nil {
457457
return nil, errors.Trace(err)
458458
}
459+
if delimiter == "" && !cmd.Flag(flag.CSVDelimiter).Changed {
460+
delimiter = defaultCsvDelimiter
461+
}
459462
trimLastSeparator, err := cmd.Flags().GetBool(flag.CSVTrimLastSeparator)
460463
if err != nil {
461464
return nil, errors.Trace(err)
@@ -464,6 +467,9 @@ func getCSVFlagValue(cmd *cobra.Command) (*imp.CSVFormat, error) {
464467
if err != nil {
465468
return nil, errors.Trace(err)
466469
}
470+
if nullValue == "" && !cmd.Flag(flag.CSVNullValue).Changed {
471+
nullValue = defaultCsvNullValue
472+
}
467473
skipHeader, err := cmd.Flags().GetBool(flag.CSVSkipHeader)
468474
if err != nil {
469475
return nil, errors.Trace(err)

internal/cli/serverless/export/create.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,16 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
487487
if err != nil {
488488
return errors.Trace(err)
489489
}
490+
if csvDelimiter == "" && !cmd.Flag(flag.CSVDelimiter).Changed {
491+
csvDelimiter = CSVDelimiterDefaultValue
492+
}
490493
csvNullValue, err = cmd.Flags().GetString(flag.CSVNullValue)
491494
if err != nil {
492495
return errors.Trace(err)
493496
}
497+
if csvNullValue == "" && !cmd.Flag(flag.CSVNullValue).Changed {
498+
csvNullValue = CSVNullValueDefaultValue
499+
}
494500
csvSkipHeader, err = cmd.Flags().GetBool(flag.CSVSkipHeader)
495501
if err != nil {
496502
return errors.Trace(err)
@@ -654,17 +660,17 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
654660
createCmd.Flags().String(flag.TableWhere, "", "Filter the exported table(s) with the where condition.")
655661
createCmd.Flags().String(flag.SQL, "", "Filter the exported data with SQL SELECT statement.")
656662
createCmd.Flags().BoolVar(&force, flag.Force, false, "Create without confirmation. You need to confirm when you want to export the whole cluster in non-interactive mode.")
657-
createCmd.Flags().String(flag.CSVDelimiter, CSVDelimiterDefaultValue, "Delimiter of string type variables in CSV files.")
663+
createCmd.Flags().String(flag.CSVDelimiter, "", "Delimiter of string type variables in CSV files. (default \"\"\")")
658664
createCmd.Flags().String(flag.CSVSeparator, CSVSeparatorDefaultValue, "Separator of each value in CSV files.")
659-
createCmd.Flags().String(flag.CSVNullValue, CSVNullValueDefaultValue, "Representation of null values in CSV files.")
665+
createCmd.Flags().String(flag.CSVNullValue, "", "Representation of null values in CSV files. (default \"\\N\")")
660666
createCmd.Flags().Bool(flag.CSVSkipHeader, CSVSkipHeaderDefaultValue, "Export CSV files of the tables without header.")
661667
createCmd.Flags().String(flag.S3RoleArn, "", "The role arn of the S3. You only need to set one of the s3.role-arn and [s3.access-key-id, s3.secret-access-key].")
662668
createCmd.Flags().String(flag.GCSURI, "", "The GCS URI in gs://<bucket>/<path> format. Required when target type is GCS.")
663669
createCmd.Flags().String(flag.GCSServiceAccountKey, "", "The base64 encoded service account key of GCS.")
664670
createCmd.Flags().String(flag.AzureBlobURI, "", "The Azure Blob URI in azure://<account>.blob.core.windows.net/<container>/<path> format. Required when target type is AZURE_BLOB.")
665671
createCmd.Flags().String(flag.AzureBlobSASToken, "", "The SAS token of Azure Blob.")
666672
createCmd.Flags().String(flag.ParquetCompression, "ZSTD", fmt.Sprintf("The parquet compression algorithm. One of %q.", export.AllowedExportParquetCompressionTypeEnumEnumValues))
667-
createCmd.Flags().String(flag.DisplayName, "", "The display name of the export. (default: SNAPSHOT_<snapshot_time>)")
673+
createCmd.Flags().String(flag.DisplayName, "", "The display name of the export. (default \"SNAPSHOT_<snapshot_time>\")")
668674

669675
createCmd.MarkFlagsMutuallyExclusive(flag.TableFilter, flag.SQL)
670676
createCmd.MarkFlagsMutuallyExclusive(flag.TableWhere, flag.SQL)

0 commit comments

Comments
 (0)