Skip to content

Commit 4aa8022

Browse files
committed
preliminary support for line renderer in max version
Abort handling still needs to be improved for both tui and ultimately line renderer, which shoudl be allowed to hide the cursor
1 parent e3d9c2f commit 4aa8022

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

Diff for: Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ small = ["lean-cli"]
3333
fast = ["git-features/parallel", "git-features/fast-sha1"]
3434
pretty-cli = ["structopt",
3535
"git-features/progress-prodash",
36-
"git-features/progress-log",
3736
"gitoxide-core/serde1",
3837
"prodash/log-renderer",
3938
"prodash-tui-renderer",

Diff for: src/plumbing/lean.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,7 @@ fn prepare(verbose: bool, name: &str) -> (Option<prodash::line::JoinHandle>, Opt
5959
if verbose {
6060
let progress = prodash::Tree::new();
6161
let sub_progress = progress.add_child(name);
62-
let output_is_terminal = atty::is(atty::Stream::Stderr);
63-
let handle = prodash::line::render(
64-
stderr(),
65-
progress,
66-
prodash::line::Options {
67-
level_filter: Some(std::ops::RangeInclusive::new(2, 2)),
68-
frames_per_second: crate::shared::DEFAULT_FRAME_RATE,
69-
initial_delay: Some(std::time::Duration::from_millis(1000)),
70-
output_is_terminal,
71-
colored: output_is_terminal && crosstermion::color::allowed(),
72-
timestamp: true,
73-
..prodash::line::Options::default()
74-
},
75-
);
62+
let handle = crate::shared::setup_line_renderer(progress, 2);
7663
(Some(handle), Some(sub_progress))
7764
} else {
7865
(None, None)

Diff for: src/plumbing/pretty.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ fn init_progress(
6363
verbose: bool,
6464
progress: bool,
6565
progress_keep_open: bool,
66-
) -> (
67-
Option<JoinThreadOnDrop>,
68-
Option<progress::Either<progress::Log, prodash::tree::Item>>,
69-
) {
70-
super::init_env_logger(verbose);
66+
) -> (Option<JoinThreadOnDrop>, Option<prodash::tree::Item>) {
67+
super::init_env_logger(false);
7168
match (verbose, progress) {
7269
(false, false) => (None, None),
73-
(true, false) => (None, Some(progress::Either::Left(progress::Log::new(name, Some(1))))),
70+
(true, false) => {
71+
let progress = prodash::Tree::new();
72+
let sub_progress = progress.add_child(name);
73+
let handle = crate::shared::setup_line_renderer(progress, 2);
74+
(Some(JoinThreadOnDrop(None, Some(handle))), Some(sub_progress))
75+
}
7476
(true, true) | (false, true) => {
7577
let progress = prodash::Tree::new();
7678
let sub_progress = progress.add_child(name);
@@ -87,15 +89,12 @@ fn init_progress(
8789
.expect("tui to come up without io error");
8890
let handle = std::thread::spawn(move || smol::run(render_tui));
8991

90-
(
91-
Some(JoinThreadOnDrop(Some(handle))),
92-
Some(progress::Either::Right(sub_progress)),
93-
)
92+
(Some(JoinThreadOnDrop(Some(handle), None)), Some(sub_progress))
9493
}
9594
}
9695
}
9796

98-
struct JoinThreadOnDrop(Option<std::thread::JoinHandle<()>>);
97+
struct JoinThreadOnDrop(Option<std::thread::JoinHandle<()>>, Option<prodash::line::JoinHandle>);
9998
impl Drop for JoinThreadOnDrop {
10099
fn drop(&mut self) {
101100
self.0.take().and_then(|handle| handle.join().ok());

Diff for: src/shared.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#[cfg(any(feature = "prodash-line-renderer", feature = "prodash-tui-renderer"))]
22
pub const DEFAULT_FRAME_RATE: f32 = 6.0;
33

4+
#[cfg(feature = "prodash-line-renderer")]
5+
pub fn setup_line_renderer(progress: prodash::Tree, level: prodash::tree::Level) -> prodash::line::JoinHandle {
6+
let output_is_terminal = atty::is(atty::Stream::Stderr);
7+
prodash::line::render(
8+
std::io::stderr(),
9+
progress,
10+
prodash::line::Options {
11+
level_filter: Some(std::ops::RangeInclusive::new(level, level)),
12+
frames_per_second: DEFAULT_FRAME_RATE,
13+
initial_delay: Some(std::time::Duration::from_millis(1000)),
14+
output_is_terminal,
15+
colored: output_is_terminal && crosstermion::color::allowed(),
16+
timestamp: true,
17+
..prodash::line::Options::default()
18+
},
19+
)
20+
}
21+
422
#[cfg(all(feature = "lean-cli", not(feature = "pretty-cli")))]
523
pub fn from_env<T: argh::TopLevelCommand>() -> T {
624
static VERSION: &str = concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION"));

0 commit comments

Comments
 (0)