feat: Use info! for progress logging

Replaces existing progress_bar.println()
This commit is contained in:
quexeky
2026-01-25 22:32:23 +11:00
parent bb3280cedf
commit 820c1b06f9
7 changed files with 9 additions and 16 deletions
+2 -4
View File
@@ -2,10 +2,7 @@ use clap::Subcommand;
use opendal::{Operator, layers::LoggingLayer}; use opendal::{Operator, layers::LoggingLayer};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::commands::{ use crate::{commands::connect::s3::{S3Config, S3ConfigCli}, operator_builder::OperatorBuilder};
connect::s3::{S3Config, S3ConfigCli},
upload::uploadable::OperatorBuilder,
};
#[derive(Subcommand, Clone)] #[derive(Subcommand, Clone)]
pub enum ConfigOptionCli { pub enum ConfigOptionCli {
@@ -18,6 +15,7 @@ pub enum ConfigOption {
impl ConfigOption { impl ConfigOption {
pub fn build(&self) -> anyhow::Result<Operator> { pub fn build(&self) -> anyhow::Result<Operator> {
Ok(match self { Ok(match self {
ConfigOption::S3(s3_config) => s3_config.build()?, ConfigOption::S3(s3_config) => s3_config.build()?,
} }
+2 -5
View File
@@ -3,11 +3,8 @@ use opendal::Operator;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
commands::{ commands::connect::{config_option::ConfigOption, configurable::Configure},
connect::{config_option::ConfigOption, configurable::Configure}, interactive_variable, operator_builder::OperatorBuilder,
upload::uploadable::OperatorBuilder,
},
interactive_variable,
}; };
#[derive(Args, Clone)] #[derive(Args, Clone)]
+2 -2
View File
@@ -4,9 +4,9 @@ use crate::{
cli::UploadInfo, cli::UploadInfo,
commands::{ commands::{
connect::config::Config, connect::config::Config,
upload::{chunk_reader::ChunkReader, uploadable::OperatorBuilder}, upload::chunk_reader::ChunkReader,
}, },
manifest::generate_manifest, manifest::generate_manifest, operator_builder::OperatorBuilder,
}; };
use futures::AsyncWriteExt; use futures::AsyncWriteExt;
use log::info; use log::info;
-1
View File
@@ -1,3 +1,2 @@
pub mod chunk_reader; pub mod chunk_reader;
pub mod interface; pub mod interface;
pub mod uploadable;
+1
View File
@@ -9,6 +9,7 @@ mod cli;
mod commands; mod commands;
mod logging; mod logging;
mod manifest; mod manifest;
mod operator_builder;
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
+2 -1
View File
@@ -2,6 +2,7 @@ use std::{collections::HashMap, path::Path};
use droplet_rs::manifest::{Manifest, generate_manifest_rusty}; use droplet_rs::manifest::{Manifest, generate_manifest_rusty};
use indicatif::{ProgressBar, ProgressStyle}; use indicatif::{ProgressBar, ProgressStyle};
use log::info;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
@@ -49,7 +50,7 @@ pub async fn generate_manifest(dir: &Path) -> anyhow::Result<Manifest> {
let progress_int = (progress * 100f32).round() as u64; let progress_int = (progress * 100f32).round() as u64;
progress_bar.set_position(progress_int); progress_bar.set_position(progress_int);
}, },
|log| progress_bar.println(log), |log| progress_bar.suspend(|| info!("{}", log)),
) )
.await .await
} }
@@ -1,8 +1,5 @@
use async_trait::async_trait;
use opendal::Operator; use opendal::Operator;
#[async_trait]
pub trait OperatorBuilder { pub trait OperatorBuilder {
fn build(&self) -> anyhow::Result<Operator>; fn build(&self) -> anyhow::Result<Operator>;
} }