Repository: influxdata/influxdb
File: influxdb3/src/commands/create.rs (Rust)

Code before:
                influxdb3_config:
                    InfluxDb3Config {
                        host_url,
                        auth_token,
                        ..
                    },
                ..
            })
            | SubCommand::Trigger(TriggerConfig {
                influxdb3_config:
                    InfluxDb3Config {
                        host_url,
                        auth_token,
                        ..
                    },
                ..
            }) => {
                let mut client = Client::new(host_url.clone())?;
                if let Some(token) = &auth_token {
                    client = client.with_auth_token(token.expose_secret());
                }
                Ok(client)
            }
            SubCommand::Token => unreachable!(),
        }
    }
}

#[derive(Debug, clap::Subcommand)]
pub enum SubCommand {
    /// Create a new database
    Database(DatabaseConfig),
    /// Create a new last value cache
    #[clap(name = "last_cache")]
    LastCache(LastCacheConfig),
    /// Create a new metadata cache
    #[clap(name = "meta_cache")]
    MetaCache(MetaCacheConfig),
    /// Create a new processing engine plugin
    Plugin(PluginConfig),
    /// Create a new table in a database
    Table(TableConfig),
    /// Create a new auth token
    Token,
    /// Create a new trigger for the processing engine
    Trigger(TriggerConfig),
}

#[derive(Debug, clap::Args)]
pub struct DatabaseConfig {
    /// The host URL of the running InfluxDB 3 Core server

Review comment (bug):
@mgattozzi - just passing by. Based on the code comments, this doesn't seem like an issue now, but does the host given to `Client::new("http://...")` need to be resolvable? I ask since it might declare intent more clearly if this was `Client::new("http://unused.invalid")` and it might prevent future bugs down the line (recall `.invalid` is a reserved domain). 2 cents

Code after:
                influxdb3_config:
                    InfluxDb3Config {
                        host_url,
                        auth_token,
                        ..
                    },
                ..
            })
            | SubCommand::Trigger(TriggerConfig {
                influxdb3_config:
                    InfluxDb3Config {
                        host_url,
                        auth_token,
                        ..
                    },
                ..
            }) => {
                let mut client = Client::new(host_url.clone())?;
                if let Some(token) = &auth_token {
                    client = client.with_auth_token(token.expose_secret());
                }
                Ok(client)
            }
            // We don't need a client for this, so we're just creating a
            // placeholder client
            SubCommand::Token => Ok(Client::new("http://localhost")?),
        }
    }
}

#[derive(Debug, clap::Subcommand)]
pub enum SubCommand {
    /// Create a new database
    Database(DatabaseConfig),
    /// Create a new last value cache
    #[clap(name = "last_cache")]
    LastCache(LastCacheConfig),
    /// Create a new metadata cache
    #[clap(name = "meta_cache")]
    MetaCache(MetaCacheConfig),
    /// Create a new processing engine plugin
    Plugin(PluginConfig),
    /// Create a new table in a database
    Table(TableConfig),
    /// Create a new auth token
    Token,
    /// Create a new trigger for the processing engine
    Trigger(TriggerConfig),
}

#[derive(Debug, clap::Args)]