Skip to content

Commit

Permalink
small build now uses the line renderer as well
Browse files Browse the repository at this point in the history
With the latest changes there is no use in using the greatly
inferior log renderer anymore.

Instead, we should go for more options to configure the line renderer
and make it leaner, for example.
  • Loading branch information
Byron committed Mar 20, 2022
1 parent 4f8dd56 commit 652a0ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fast = ["git-features/parallel", "git-features/fast-sha1", "git-features/zlib-ng
## Use `clap` 3.0 to build the prettiest, best documented and most user-friendly CLI at the expense of binary size.
## Provides a terminal user interface for detailed and exhaustive progress.
## Provides a line renderer for leaner progress display, without the need for a full-blown TUI.
pretty-cli = [ "gitoxide-core/serde1", "prodash/progress-tree", "prodash/progress-tree-log", "prodash/local-time", "gitoxide-core/local-time-support", "env_logger" ]
pretty-cli = [ "gitoxide-core/serde1", "prodash/progress-tree", "prodash/progress-tree-log", "prodash/local-time", "gitoxide-core/local-time-support", "env_logger/humantime", "env_logger/termcolor", "env_logger/atty" ]

## The `--verbose` flag will be powered by an interactive progress mechanism that doubles as log as well as interactive progress
## that appears after a short duration.
Expand All @@ -57,7 +57,7 @@ lean-async = ["fast", "pretty-cli", "gitoxide-core-tools", "gitoxide-core-async-

## As small as it can possibly be, no threading, no fast sha1, log based progress only, rust based zlib implementation.
## no networking, local operations only.
small = ["pretty-cli", "git-features/rustsha1", "git-features/zlib-rust-backend", "prodash/progress-log", "atty", "env_logger"]
small = ["pretty-cli", "git-features/rustsha1", "git-features/zlib-rust-backend", "prodash-render-line", "atty" ]

#! ### `gitoxide-core` Configuration

Expand Down Expand Up @@ -91,7 +91,7 @@ git-transport-for-configuration-only = { package = "git-transport", optional = t
clap = { version = "3.0.0", features = ["derive", "cargo"] }
prodash = { version = "19.0.0", optional = true, default-features = false }
atty = { version = "0.2.14", optional = true, default-features = false }
env_logger = { version = "0.9.0", optional = true, default-features = false, features = ["humantime", "termcolor", "atty"] }
env_logger = { version = "0.9.0", default-features = false }
crosstermion = { version = "0.9.0", optional = true, default-features = false }
futures-lite = { version = "1.12.0", optional = true, default-features = false, features = ["std"] }

Expand Down
37 changes: 9 additions & 28 deletions src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub const STANDARD_RANGE: ProgressRange = 2..=2;

/// If verbose is true, the env logger will be forcibly set to 'info' logging level. Otherwise env logging facilities
/// will just be initialized.
#[cfg(feature = "env_logger")]
#[allow(unused)] // Squelch warning because it's used in porcelain as well and we can't know that at compile time
pub fn init_env_logger() {
if cfg!(feature = "small") {
Expand Down Expand Up @@ -59,13 +58,7 @@ pub mod pretty {
progress: bool,
#[cfg_attr(not(feature = "prodash-render-tui"), allow(unused_variables))] progress_keep_open: bool,
#[cfg_attr(not(feature = "prodash-render-line"), allow(unused_variables))] range: impl Into<Option<ProgressRange>>,
#[cfg(not(any(feature = "prodash-render-line", feature = "prodash-render-tui")))] run: impl FnOnce(
progress::DoOrDiscard<prodash::progress::Log>,
&mut dyn std::io::Write,
&mut dyn std::io::Write,
)
-> Result<T>,
#[cfg(any(feature = "prodash-render-line", feature = "prodash-render-tui"))] run: impl FnOnce(
run: impl FnOnce(
progress::DoOrDiscard<prodash::tree::Item>,
&mut dyn std::io::Write,
&mut dyn std::io::Write,
Expand All @@ -87,27 +80,15 @@ pub mod pretty {
(true, false) => {
let progress = crate::shared::progress_tree();
let sub_progress = progress.add_child(name);
#[cfg(not(feature = "prodash-render-line"))]
{
let stdout = stdout();
let mut stdout_lock = stdout.lock();
run(
progress::DoOrDiscard::from(Some(sub_progress)),
&mut stdout_lock,
&mut stderr(),
)
}
#[cfg(feature = "prodash-render-line")]
{
use crate::shared::{self, STANDARD_RANGE};
let handle = shared::setup_line_renderer_range(&progress, range.into().unwrap_or(STANDARD_RANGE));

let mut out = Vec::<u8>::new();
let res = run(progress::DoOrDiscard::from(Some(sub_progress)), &mut out, &mut stderr());
handle.shutdown_and_wait();
std::io::Write::write_all(&mut stdout(), &out)?;
res
}
use crate::shared::{self, STANDARD_RANGE};
let handle = shared::setup_line_renderer_range(&progress, range.into().unwrap_or(STANDARD_RANGE));

let mut out = Vec::<u8>::new();
let res = run(progress::DoOrDiscard::from(Some(sub_progress)), &mut out, &mut stderr());
handle.shutdown_and_wait();
std::io::Write::write_all(&mut stdout(), &out)?;
res
}
#[cfg(not(feature = "prodash-render-tui"))]
(true, true) | (false, true) => {
Expand Down

0 comments on commit 652a0ac

Please sign in to comment.