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

Code before:
    /// Common InfluxDB 3 Core config
    #[clap(flatten)]
    influxdb3_config: InfluxDb3Config,

    /// File path to load the write data from
    ///
    /// Currently, only files containing line protocol are supported.
    #[clap(short = 'f', long = "file")]
    file_path: Option<String>,

    /// Flag to request the server accept partial writes
    ///
    /// Invalid lines in the input data will be ignored by the server.
    #[clap(long = "accept-partial")]
    accept_partial_writes: bool,

    /// Give a quoted line protocol line via the command line
    line_protocol: Option<Vec<String>>,

    /// Specify a supported precision (eg: ns, us, ms, s).
    #[clap(short = 'p', long = "precision")]
    precision: Option<Precision>,

    /// An optional arg to use a custom ca for useful for testing with self signed certs
    #[clap(long = "tls-ca", env = "INFLUXDB3_TLS_CA")]
    ca_cert: Option<PathBuf>,
}

pub(crate) async fn command(config: Config) -> Result<()> {
    let InfluxDb3Config {
        host_url,
        database_name,
        auth_token,
    } = config.influxdb3_config;
    let mut client = influxdb3_client::Client::new(host_url, config.ca_cert)?;
    if let Some(t) = auth_token {
        client = client.with_auth_token(t.expose_secret());
    }

    let writes = if let Some(line) = config.line_protocol {
        parse_line(line)?
    } else if let Some(file_path) = config.file_path {
        fs::read_to_string(file_path)?
    } else {
        let stdin = stdin();
        // Checks if stdin has had data passed to it via a pipe
        if stdin.is_terminal() {
            return Err(Error::NoInput);
        }
        let mut reader = BufReader::new(stdin);
        let mut buffer = String::new();

Review comment (suggestion):
I believe `auto` is left out as server sets it to `Precision::Auto` when it's not passed through, so users can leave out this argument when calling `influxdb3 write`.  https://github.com/influxdata/influxdb/blob/8dcb92c6549bbd4e79f92f90bb69ef925deba67d/influxdb3_server/src/http.rs#L636

I don't think there's any harm in exposing it, but setting explicitly to `auto` on client might be redundant.

Code after:
    /// Common InfluxDB 3 Core config
    #[clap(flatten)]
    influxdb3_config: InfluxDb3Config,

    /// File path to load the write data from
    ///
    /// Currently, only files containing line protocol are supported.
    #[clap(short = 'f', long = "file")]
    file_path: Option<String>,

    /// Flag to request the server accept partial writes
    ///
    /// Invalid lines in the input data will be ignored by the server.
    #[clap(long = "accept-partial")]
    accept_partial_writes: bool,

    /// Flag to request the server not wait for sync before ACK'ing
    ///
    /// This option returns a success before a write is durable.
    #[clap(long = "no-sync")]
    no_sync_writes: bool,

    /// Give a quoted line protocol line via the command line
    line_protocol: Option<Vec<String>>,

    /// Specify a supported precision (eg: auto, ns, us, ms, s).
    #[clap(short = 'p', long = "precision")]
    precision: Option<Precision>,

    /// An optional arg to use a custom ca for useful for testing with self signed certs
    #[clap(long = "tls-ca", env = "INFLUXDB3_TLS_CA")]
    ca_cert: Option<PathBuf>,
}

pub(crate) async fn command(config: Config) -> Result<()> {
    let InfluxDb3Config {
        host_url,
        database_name,
        auth_token,
    } = config.influxdb3_config;
    let mut client = influxdb3_client::Client::new(host_url, config.ca_cert)?;
    if let Some(t) = auth_token {
        client = client.with_auth_token(t.expose_secret());
    }

    let writes = if let Some(line) = config.line_protocol {
        parse_line(line)?
    } else if let Some(file_path) = config.file_path {
        fs::read_to_string(file_path)?
    } else {
        let stdin = stdin();