Skip to content

Commit

Permalink
Fix compile warning (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 5, 2021
1 parent 4bd2f29 commit e4514a8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
36 changes: 29 additions & 7 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ use gitoxide_core::pack::verify;
use crate::plumbing::options::{Args, Subcommands};
use crate::shared::pretty::prepare_and_run;

#[cfg(feature = "gitoxide-core-async-client")]
pub mod async_util {
use crate::shared::ProgressRange;

#[cfg(not(feature = "prodash-render-line"))]
compile_error!("BUG: Need at least a line renderer in async mode");

pub fn prepare(
verbose: bool,
name: &str,
range: impl Into<Option<ProgressRange>>,
) -> (Option<prodash::render::line::JoinHandle>, Option<prodash::tree::Item>) {
use crate::shared::{self, STANDARD_RANGE};
crate::shared::init_env_logger(false);

if verbose {
let progress = crate::shared::progress_tree();
let sub_progress = progress.add_child(name);
let ui_handle = shared::setup_line_renderer_range(progress, range.into().unwrap_or(STANDARD_RANGE));
(Some(ui_handle), Some(sub_progress))
} else {
(None, None)
}
}
}

pub fn main() -> Result<()> {
let args: Args = Args::parse();
let thread_limit = args.threads;
Expand Down Expand Up @@ -101,8 +127,7 @@ pub fn main() -> Result<()> {
refs,
refs_directory,
} => {
let (_handle, progress) =
crate::shared::async_util::prepare(verbose, "pack-receive", core::pack::receive::PROGRESS_RANGE);
let (_handle, progress) = async_util::prepare(verbose, "pack-receive", core::pack::receive::PROGRESS_RANGE);
let fut = core::pack::receive(
protocol,
&url,
Expand Down Expand Up @@ -151,11 +176,8 @@ pub fn main() -> Result<()> {
),
#[cfg(feature = "gitoxide-core-async-client")]
Subcommands::RemoteRefList { protocol, url } => {
let (_handle, progress) = crate::shared::async_util::prepare(
verbose,
"remote-ref-list",
Some(core::remote::refs::PROGRESS_RANGE),
);
let (_handle, progress) =
async_util::prepare(verbose, "remote-ref-list", Some(core::remote::refs::PROGRESS_RANGE));
let fut = core::remote::refs::list(
protocol,
&url,
Expand Down
28 changes: 1 addition & 27 deletions src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn init_env_logger(verbose: bool) {
}

#[cfg(feature = "prodash-render-line")]
fn progress_tree() -> prodash::Tree {
pub fn progress_tree() -> prodash::Tree {
prodash::TreeOptions {
message_buffer_capacity: 200,
..Default::default()
Expand All @@ -44,32 +44,6 @@ fn progress_tree() -> LogCreator {
LogCreator
}

#[cfg(feature = "gitoxide-core-async-client")]
pub mod async_util {
use crate::shared::ProgressRange;

#[cfg(not(feature = "prodash-render-line"))]
compile_error!("BUG: Need at least a line renderer in async mode");

pub fn prepare(
verbose: bool,
name: &str,
range: impl Into<Option<ProgressRange>>,
) -> (Option<prodash::render::line::JoinHandle>, Option<prodash::tree::Item>) {
use crate::shared::{self, STANDARD_RANGE};
super::init_env_logger(false);

if verbose {
let progress = crate::shared::progress_tree();
let sub_progress = progress.add_child(name);
let ui_handle = shared::setup_line_renderer_range(progress, range.into().unwrap_or(STANDARD_RANGE));
(Some(ui_handle), Some(sub_progress))
} else {
(None, None)
}
}
}

#[cfg(feature = "pretty-cli")]
pub mod pretty {
use std::io::{stderr, stdout};
Expand Down

0 comments on commit e4514a8

Please sign in to comment.