Skip to content

Commit

Permalink
fix alias
Browse files Browse the repository at this point in the history
  • Loading branch information
shijiesheng committed Sep 13, 2024
1 parent 91b2267 commit 3f80731
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 21 deletions.
18 changes: 18 additions & 0 deletions tools/cassandra/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,41 @@ func BuildCLIOptions() *cli.App {
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagEndpoint,
Aliases: []string{"ep"},
Value: "127.0.0.1",
Usage: "hostname or ip address of cassandra host to connect to",
EnvVars: []string{"CASSANDRA_HOST"},
},
&cli.IntFlag{
Name: schema.CLIFlagPort,
Aliases: []string{"p"},
Value: DefaultCassandraPort,
Usage: "Port of cassandra host to connect to",
EnvVars: []string{"CASSANDRA_DB_PORT"},
},
&cli.StringFlag{
Name: schema.CLIFlagUser,
Aliases: []string{"u"},
Value: "",
Usage: "User name used for authentication for connecting to cassandra host",
EnvVars: []string{"CASSANDRA_USER"},
},
&cli.StringFlag{
Name: schema.CLIFlagPassword,
Aliases: []string{"pw"},
Value: "",
Usage: "Password used for authentication for connecting to cassandra host",
EnvVars: []string{"CASSANDRA_PASSWORD"},
},
&cli.StringSliceFlag{
Name: schema.CLIFlagAllowedAuthenticators,
Aliases: []string{"aa"},
Value: cli.NewStringSlice(""),
Usage: "Set allowed authenticators for servers with custom authenticators",
},
&cli.IntFlag{
Name: schema.CLIFlagTimeout,
Aliases: []string{"t"},
Value: DefaultTimeout,
Usage: "request Timeout in seconds used for cql client",
EnvVars: []string{"CASSANDRA_TIMEOUT"},
Expand All @@ -110,16 +116,19 @@ func BuildCLIOptions() *cli.App {
},
&cli.StringFlag{
Name: schema.CLIFlagKeyspace,
Aliases: []string{"k"},
Value: "cadence",
Usage: "name of the cassandra Keyspace",
EnvVars: []string{"CASSANDRA_KEYSPACE"},
},
&cli.BoolFlag{
Name: schema.CLIFlagQuiet,
Aliases: []string{"q"},
Usage: "Don't set exit status to 1 on error",
},
&cli.IntFlag{
Name: schema.CLIFlagProtoVersion,
Aliases: []string{"pv"},
Usage: "Protocol Version to connect to cassandra host",
EnvVars: []string{"CASSANDRA_PROTO_VERSION"},
},
Expand Down Expand Up @@ -164,18 +173,22 @@ func BuildCLIOptions() *cli.App {
Flags: []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagVersion,
Aliases: []string{"v"},
Usage: "initial version of the schema, cannot be used with disable-versioning",
},
&cli.StringFlag{
Name: schema.CLIFlagSchemaFile,
Aliases: []string{"f"},
Usage: "path to the .cql schema file; if un-specified, will just setup versioning tables",
},
&cli.BoolFlag{
Name: schema.CLIFlagDisableVersioning,
Aliases: []string{"d"},
Usage: "disable setup of schema versioning",
},
&cli.BoolFlag{
Name: schema.CLIFlagOverwrite,
Aliases: []string{"o"},
Usage: "drop all existing tables before setting up new schema",
},
},
Expand All @@ -190,10 +203,12 @@ func BuildCLIOptions() *cli.App {
Flags: []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagTargetVersion,
Aliases: []string{"v"},
Usage: "target version for the schema update, defaults to latest",
},
&cli.StringFlag{
Name: schema.CLIFlagSchemaDir,
Aliases: []string{"d"},
Usage: "path to directory containing versioned schema",
},
&cli.BoolFlag{
Expand All @@ -212,15 +227,18 @@ func BuildCLIOptions() *cli.App {
Flags: []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagKeyspace,
Aliases: []string{"k"},
Usage: "name of the Keyspace",
},
&cli.StringFlag{
Name: schema.CLIFlagDatacenter,
Aliases: []string{"dc"},
Value: "",
Usage: "name of the cassandra datacenter, used when creating the keyspace with network topology strategy",
},
&cli.IntFlag{
Name: schema.CLIFlagReplicationFactor,
Aliases: []string{"rf"},
Value: 1,
Usage: "replication factor for the Keyspace",
},
Expand Down
42 changes: 21 additions & 21 deletions tools/common/schema/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,49 +115,49 @@ const (
CLIOptProtoVersion = "protocol-version"

// CLIFlagEndpoint is the cli flag for endpoint
CLIFlagEndpoint = CLIOptEndpoint + ", ep"
CLIFlagEndpoint = CLIOptEndpoint
// CLIFlagPort is the cli flag for port
CLIFlagPort = CLIOptPort + ", p"
CLIFlagPort = CLIOptPort
// CLIFlagUser is the cli flag for user
CLIFlagUser = CLIOptUser + ", u"
CLIFlagUser = CLIOptUser
// CLIFlagPassword is the cli flag for password
CLIFlagPassword = CLIOptPassword + ", pw"
CLIFlagPassword = CLIOptPassword
// CLIFlagAllowedAuthenticators is the cli flag for whitelisting custom authenticators
CLIFlagAllowedAuthenticators = CLIOptAllowedAuthenticators + ", aa"
CLIFlagAllowedAuthenticators = CLIOptAllowedAuthenticators
// CLIFlagConnectTimeout is the cli flag for connection timeout
CLIFlagConnectTimeout = CLIOptConnectTimeout + ", ct"
CLIFlagConnectTimeout = CLIOptConnectTimeout
// CLIFlagTimeout is the cli flag for timeout
CLIFlagTimeout = CLIOptTimeout + ", t"
CLIFlagTimeout = CLIOptTimeout
// CLIFlagKeyspace is the cli flag for keyspace
CLIFlagKeyspace = CLIOptKeyspace + ", k"
CLIFlagKeyspace = CLIOptKeyspace
// CLIFlagDatacenter is the cli flag for datacenter
CLIFlagDatacenter = CLIOptDatacenter + ", dc"
CLIFlagDatacenter = CLIOptDatacenter
// CLIFlagDatabase is the cli flag for database
CLIFlagDatabase = CLIOptDatabase + ", db"
CLIFlagDatabase = CLIOptDatabase
// CLIFlagPluginName is the cli flag for plugin name
CLIFlagPluginName = CLIOptPluginName + ", pl"
CLIFlagPluginName = CLIOptPluginName
// CLIFlagConnectAttributes allows arbitrary connect attributes
CLIFlagConnectAttributes = CLIOptConnectAttributes + ", ca"
CLIFlagConnectAttributes = CLIOptConnectAttributes
// CLIFlagVersion is the cli flag for version
CLIFlagVersion = CLIOptVersion + ", v"
CLIFlagVersion = CLIOptVersion
// CLIFlagSchemaFile is the cli flag for schema file
CLIFlagSchemaFile = CLIOptSchemaFile + ", f"
CLIFlagSchemaFile = CLIOptSchemaFile
// CLIFlagOverwrite is the cli flag for overwrite
CLIFlagOverwrite = CLIOptOverwrite + ", o"
CLIFlagOverwrite = CLIOptOverwrite
// CLIFlagDisableVersioning is the cli flag for disabling versioning
CLIFlagDisableVersioning = CLIOptDisableVersioning + ", d"
CLIFlagDisableVersioning = CLIOptDisableVersioning
// CLIFlagTargetVersion is the cli flag for target version
CLIFlagTargetVersion = CLIOptTargetVersion + ", v"
CLIFlagTargetVersion = CLIOptTargetVersion
// CLIFlagDryrun is the cli flag for dryrun
CLIFlagDryrun = CLIOptDryrun
// CLIFlagSchemaDir is the cli flag for schema directory
CLIFlagSchemaDir = CLIOptSchemaDir + ", d"
CLIFlagSchemaDir = CLIOptSchemaDir
// CLIFlagReplicationFactor is the cli flag for replication factor
CLIFlagReplicationFactor = CLIOptReplicationFactor + ", rf"
CLIFlagReplicationFactor = CLIOptReplicationFactor
// CLIFlagQuiet is the cli flag for quiet mode
CLIFlagQuiet = CLIOptQuiet + ", q"
CLIFlagQuiet = CLIOptQuiet
// CLIFlagProtoVersion is the cli flag for protocol version
CLIFlagProtoVersion = CLIOptProtoVersion + ", pv"
CLIFlagProtoVersion = CLIOptProtoVersion

// CLIFlagEnableTLS enables cassandra client TLS
CLIFlagEnableTLS = "tls"
Expand Down
15 changes: 15 additions & 0 deletions tools/sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,46 +60,54 @@ func BuildCLIOptions() *cli.App {
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagEndpoint,
Aliases: []string{"ep"},
Value: "127.0.0.1",
Usage: "hostname or ip address of sql host to connect to",
EnvVars: []string{"SQL_HOST"},
},
&cli.IntFlag{
Name: schema.CLIFlagPort,
Aliases: []string{"p"},
Value: defaultSQLPort,
Usage: "port of sql host to connect to",
EnvVars: []string{"SQL_PORT"},
},
&cli.StringFlag{
Name: schema.CLIFlagUser,
Aliases: []string{"u"},
Value: "",
Usage: "user name used for authentication when connecting to sql host",
EnvVars: []string{"SQL_USER"},
},
&cli.StringFlag{
Name: schema.CLIFlagPassword,
Aliases: []string{"pw"},
Value: "",
Usage: "password used for authentication when connecting to sql host",
EnvVars: []string{"SQL_PASSWORD"},
},
&cli.StringFlag{
Name: schema.CLIFlagDatabase,
Aliases: []string{"db"},
Value: "cadence",
Usage: "name of the sql database",
EnvVars: []string{"SQL_DATABASE"},
},
&cli.StringFlag{
Name: schema.CLIFlagPluginName,
Aliases: []string{"pl"},
Value: "mysql",
Usage: "name of the sql plugin",
EnvVars: []string{"SQL_PLUGIN"},
},
&cli.BoolFlag{
Name: schema.CLIFlagQuiet,
Aliases: []string{"q"},
Usage: "Don't set exit status to 1 on error",
},
&cli.GenericFlag{
Name: schema.CLIFlagConnectAttributes,
Aliases: []string{"ca"},
Value: &cliflag.StringMap{},
Usage: "sql connect attributes (must be in key1=value1,key2=value2,...,keyN=valueN format, e.g. cluster=dca or cluster=dca,instance=cadence)",
EnvVars: []string{"SQL_CONNECT_ATTRIBUTES"},
Expand Down Expand Up @@ -139,18 +147,22 @@ func BuildCLIOptions() *cli.App {
Flags: []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagVersion,
Aliases: []string{"v"},
Usage: "initial version of the schema, cannot be used with disable-versioning",
},
&cli.StringFlag{
Name: schema.CLIFlagSchemaFile,
Aliases: []string{"f"},
Usage: "path to the .sql schema file; if un-specified, will just setup versioning tables",
},
&cli.BoolFlag{
Name: schema.CLIFlagDisableVersioning,
Aliases: []string{"d"},
Usage: "disable setup of schema versioning",
},
&cli.BoolFlag{
Name: schema.CLIFlagOverwrite,
Aliases: []string{"o"},
Usage: "drop all existing tables before setting up new schema",
},
},
Expand All @@ -165,10 +177,12 @@ func BuildCLIOptions() *cli.App {
Flags: []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagTargetVersion,
Aliases: []string{"v"},
Usage: "target version for the schema update, defaults to latest",
},
&cli.StringFlag{
Name: schema.CLIFlagSchemaDir,
Aliases: []string{"d"},
Usage: "path to directory containing versioned schema",
},
&cli.BoolFlag{
Expand All @@ -187,6 +201,7 @@ func BuildCLIOptions() *cli.App {
Flags: []cli.Flag{
&cli.StringFlag{
Name: schema.CLIFlagDatabase,
Aliases: []string{"db"},
Usage: "name of the database",
},
},
Expand Down

0 comments on commit 3f80731

Please sign in to comment.