Skip to content

Commit

Permalink
Standardize Output Format for Default Values
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanyu66 committed Jan 20, 2025
1 parent 95a6bc0 commit 78754f9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/generate_doc/ticloud_serverless_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ticloud serverless create [flags]
-n, --display-name string Display name of the cluster to de created.
--encryption Whether Enhanced Encryption at Rest is enabled.
-h, --help help for create
-p, --project-id string The ID of the project, in which the cluster will be created. (default: "default project")
-p, --project-id string The ID of the project, in which the cluster will be created. (default "default project")
-r, --region string The name of cloud region. You can use "ticloud serverless region" to see all regions.
--spending-limit-monthly int32 Maximum monthly spending limit in USD cents. (optional)
```
Expand Down
6 changes: 3 additions & 3 deletions docs/generate_doc/ticloud_serverless_export_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ ticloud serverless export create [flags]
--azblob.uri string The Azure Blob URI in azure://<account>.blob.core.windows.net/<container>/<path> format. Required when target type is AZURE_BLOB.
-c, --cluster-id string The ID of the cluster, in which the export will be created.
--compression string The compression algorithm of the export file. One of ["GZIP" "SNAPPY" "ZSTD" "NONE"].
--csv.delimiter string Delimiter of string type variables in CSV files. (default "\"")
--csv.null-value string Representation of null values in CSV files. (default "\\N")
--csv.delimiter string Delimiter of string type variables in CSV files. (default """)
--csv.null-value string Representation of null values in CSV files. (default "\N")
--csv.separator string Separator of each value in CSV files. (default ",")
--csv.skip-header Export CSV files of the tables without header.
--display-name string The display name of the export. (default: SNAPSHOT_<snapshot_time>)
--display-name string The display name of the export. (default "SNAPSHOT_<snapshot_time>")
--file-type string The export file type. One of ["SQL" "CSV" "PARQUET"]. (default "CSV")
--filter strings Specify the exported table(s) with table filter patterns. See https://docs.pingcap.com/tidb/stable/table-filter to learn table filter.
--force Create without confirmation. You need to confirm when you want to export the whole cluster in non-interactive mode.
Expand Down
4 changes: 2 additions & 2 deletions docs/generate_doc/ticloud_serverless_import_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ ticloud serverless import start [flags]
--azblob.uri string The Azure Blob URI in azure://<account>.blob.core.windows.net/<container>/<path> format.
-c, --cluster-id string Cluster ID.
--csv.backslash-escape Specifies whether to interpret backslash escapes inside fields in the CSV file. (default true)
--csv.delimiter string The delimiter used for quoting of CSV file. (default "\"")
--csv.delimiter string The delimiter used for quoting of CSV file. (default """)
--csv.not-null Specifies whether a CSV file can contain any NULL values.
--csv.null-value string The representation of NULL values in the CSV file. (default "\\N")
--csv.null-value string The representation of NULL values in the CSV file. (default "\N")
--csv.separator string The field separator of CSV file. (default ",")
--csv.skip-header Specifies whether the CSV file contains a header line.
--csv.trim-last-separator Specifies whether to treat separator as the line terminator and trim all trailing separators in the CSV file.
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/serverless/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command {

createCmd.Flags().StringP(flag.DisplayName, flag.DisplayNameShort, "", "Display name of the cluster to de created.")
createCmd.Flags().StringP(flag.Region, flag.RegionShort, "", "The name of cloud region. You can use \"ticloud serverless region\" to see all regions.")
createCmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "The ID of the project, in which the cluster will be created. (default: \"default project\")")
createCmd.Flags().StringP(flag.ProjectID, flag.ProjectIDShort, "", "The ID of the project, in which the cluster will be created. (default \"default project\")")
createCmd.Flags().Int32(flag.SpendingLimitMonthly, 0, "Maximum monthly spending limit in USD cents. (optional)")
createCmd.Flags().Bool(flag.Encryption, false, "Whether Enhanced Encryption at Rest is enabled.")
createCmd.Flags().Bool(flag.PublicEndpointDisabled, false, "Whether the public endpoint is disabled.")
Expand Down
10 changes: 8 additions & 2 deletions internal/cli/serverless/dataimport/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ func StartCmd(h *internal.Helper) *cobra.Command {
startCmd.Flags().String(flag.AzureBlobURI, "", "The Azure Blob URI in azure://<account>.blob.core.windows.net/<container>/<path> format.")
startCmd.Flags().String(flag.AzureBlobSASToken, "", "The SAS token of Azure Blob.")

startCmd.Flags().String(flag.CSVDelimiter, defaultCsvDelimiter, "The delimiter used for quoting of CSV file.")
startCmd.Flags().String(flag.CSVDelimiter, "", "The delimiter used for quoting of CSV file. (default \"\"\")")
startCmd.Flags().String(flag.CSVSeparator, defaultCsvSeparator, "The field separator of CSV file.")
startCmd.Flags().Bool(flag.CSVTrimLastSeparator, defaultCsvTrimLastSeparator, "Specifies whether to treat separator as the line terminator and trim all trailing separators in the CSV file.")
startCmd.Flags().Bool(flag.CSVBackslashEscape, defaultCsvBackslashEscape, "Specifies whether to interpret backslash escapes inside fields in the CSV file.")
startCmd.Flags().Bool(flag.CSVNotNull, defaultCsvNotNull, "Specifies whether a CSV file can contain any NULL values.")
startCmd.Flags().String(flag.CSVNullValue, defaultCsvNullValue, "The representation of NULL values in the CSV file.")
startCmd.Flags().String(flag.CSVNullValue, "", "The representation of NULL values in the CSV file. (default \"\\N\")")
startCmd.Flags().Bool(flag.CSVSkipHeader, defaultCsvSkipHeader, "Specifies whether the CSV file contains a header line.")
return startCmd
}
Expand Down Expand Up @@ -456,6 +456,9 @@ func getCSVFlagValue(cmd *cobra.Command) (*imp.CSVFormat, error) {
if err != nil {
return nil, errors.Trace(err)
}
if delimiter == "" && !cmd.Flag(flag.CSVDelimiter).Changed {
delimiter = defaultCsvDelimiter
}
trimLastSeparator, err := cmd.Flags().GetBool(flag.CSVTrimLastSeparator)
if err != nil {
return nil, errors.Trace(err)
Expand All @@ -464,6 +467,9 @@ func getCSVFlagValue(cmd *cobra.Command) (*imp.CSVFormat, error) {
if err != nil {
return nil, errors.Trace(err)
}
if nullValue == "" && !cmd.Flag(flag.CSVNullValue).Changed {
nullValue = defaultCsvNullValue
}
skipHeader, err := cmd.Flags().GetBool(flag.CSVSkipHeader)
if err != nil {
return nil, errors.Trace(err)
Expand Down
12 changes: 9 additions & 3 deletions internal/cli/serverless/export/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,16 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
if err != nil {
return errors.Trace(err)
}
if csvDelimiter == "" && !cmd.Flag(flag.CSVDelimiter).Changed {
csvDelimiter = CSVDelimiterDefaultValue
}
csvNullValue, err = cmd.Flags().GetString(flag.CSVNullValue)
if err != nil {
return errors.Trace(err)
}
if csvNullValue == "" && !cmd.Flag(flag.CSVNullValue).Changed {
csvNullValue = CSVNullValueDefaultValue
}
csvSkipHeader, err = cmd.Flags().GetBool(flag.CSVSkipHeader)
if err != nil {
return errors.Trace(err)
Expand Down Expand Up @@ -654,17 +660,17 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
createCmd.Flags().String(flag.TableWhere, "", "Filter the exported table(s) with the where condition.")
createCmd.Flags().String(flag.SQL, "", "Filter the exported data with SQL SELECT statement.")
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.")
createCmd.Flags().String(flag.CSVDelimiter, CSVDelimiterDefaultValue, "Delimiter of string type variables in CSV files.")
createCmd.Flags().String(flag.CSVDelimiter, "", "Delimiter of string type variables in CSV files. (default \"\"\")")
createCmd.Flags().String(flag.CSVSeparator, CSVSeparatorDefaultValue, "Separator of each value in CSV files.")
createCmd.Flags().String(flag.CSVNullValue, CSVNullValueDefaultValue, "Representation of null values in CSV files.")
createCmd.Flags().String(flag.CSVNullValue, "", "Representation of null values in CSV files. (default \"\\N\")")
createCmd.Flags().Bool(flag.CSVSkipHeader, CSVSkipHeaderDefaultValue, "Export CSV files of the tables without header.")
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].")
createCmd.Flags().String(flag.GCSURI, "", "The GCS URI in gs://<bucket>/<path> format. Required when target type is GCS.")
createCmd.Flags().String(flag.GCSServiceAccountKey, "", "The base64 encoded service account key of GCS.")
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.")
createCmd.Flags().String(flag.AzureBlobSASToken, "", "The SAS token of Azure Blob.")
createCmd.Flags().String(flag.ParquetCompression, "ZSTD", fmt.Sprintf("The parquet compression algorithm. One of %q.", export.AllowedExportParquetCompressionTypeEnumEnumValues))
createCmd.Flags().String(flag.DisplayName, "", "The display name of the export. (default: SNAPSHOT_<snapshot_time>)")
createCmd.Flags().String(flag.DisplayName, "", "The display name of the export. (default \"SNAPSHOT_<snapshot_time>\")")

createCmd.MarkFlagsMutuallyExclusive(flag.TableFilter, flag.SQL)
createCmd.MarkFlagsMutuallyExclusive(flag.TableWhere, flag.SQL)
Expand Down

0 comments on commit 78754f9

Please sign in to comment.