Display progress.
This commit is contained in:
@@ -202,6 +202,68 @@ impl Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_progress_text(&self) -> Option<Cow<'_, str>> {
|
||||||
|
match self {
|
||||||
|
Activity::Root(_activity_root) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a root activity.");
|
||||||
|
}
|
||||||
|
Activity::Unknown(_activity_unknown) => None,
|
||||||
|
Activity::CopyPath(activity_copy_path) => Some(Cow::Owned(format!(
|
||||||
|
"[{}/{}]",
|
||||||
|
activity_copy_path.done, activity_copy_path.expected
|
||||||
|
))),
|
||||||
|
Activity::FileTransfer(activity_file_transfer) => Some(Cow::Owned(format!(
|
||||||
|
"[{}/{}]",
|
||||||
|
activity_file_transfer.done, activity_file_transfer.expected
|
||||||
|
))),
|
||||||
|
Activity::Realize(_activity_realize) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a realize activity.");
|
||||||
|
}
|
||||||
|
Activity::CopyPaths(activity_copy_paths) => Some(Cow::Owned(format!(
|
||||||
|
"[{}/{}]",
|
||||||
|
activity_copy_paths.done, activity_copy_paths.expected
|
||||||
|
))),
|
||||||
|
Activity::Builds(activity_builds) => Some(Cow::Owned(format!(
|
||||||
|
"[{}/{}]",
|
||||||
|
activity_builds.done, activity_builds.expected
|
||||||
|
))),
|
||||||
|
Activity::Build(activity_build) => activity_build
|
||||||
|
.phase
|
||||||
|
.as_ref()
|
||||||
|
.map(|phase| Cow::Owned(format!("[{}]", phase))),
|
||||||
|
Activity::OptimizeStore(_activity_optimize_store) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a optimize store activity.");
|
||||||
|
}
|
||||||
|
Activity::VerifyPaths(_activity_verify_paths) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a verify paths activity.");
|
||||||
|
}
|
||||||
|
Activity::Substitute(_activity_substitute) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a substitute activity.");
|
||||||
|
}
|
||||||
|
Activity::QueryPathInfo(_activity_query_path_info) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a query path info activity.");
|
||||||
|
}
|
||||||
|
Activity::PostBuildHook(_activity_post_build_hook) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a post build hook activity.");
|
||||||
|
}
|
||||||
|
Activity::BuildWaiting(_activity_build_waiting) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a build waiting activity.");
|
||||||
|
}
|
||||||
|
Activity::FetchTree(_activity_fetch_tree) => {
|
||||||
|
// TODO
|
||||||
|
panic!("Attempted to get_progress_text of a fetch tree activity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn set_phase(&mut self, phase: Option<String>) -> () {
|
pub(crate) fn set_phase(&mut self, phase: Option<String>) -> () {
|
||||||
match self {
|
match self {
|
||||||
Activity::Root(_activity_root) => {
|
Activity::Root(_activity_root) => {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
use tokio::process::Child;
|
use tokio::process::Child;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
@@ -302,6 +304,8 @@ impl<'db> RunningBuild<'db> {
|
|||||||
activity
|
activity
|
||||||
.get_mut_activity()
|
.get_mut_activity()
|
||||||
.set_phase(Some(activity_result_set_phase.phase));
|
.set_phase(Some(activity_result_set_phase.phase));
|
||||||
|
|
||||||
|
self.print_current_status();
|
||||||
}
|
}
|
||||||
ActivityResultMessage::Progress(activity_result_progress) => {
|
ActivityResultMessage::Progress(activity_result_progress) => {
|
||||||
let activity_id = self
|
let activity_id = self
|
||||||
@@ -314,6 +318,8 @@ impl<'db> RunningBuild<'db> {
|
|||||||
activity_result_progress.running,
|
activity_result_progress.running,
|
||||||
activity_result_progress.failed,
|
activity_result_progress.failed,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.print_current_status();
|
||||||
}
|
}
|
||||||
ActivityResultMessage::SetExpected(activity_result_set_expected) => {
|
ActivityResultMessage::SetExpected(activity_result_set_expected) => {
|
||||||
let activity_id = self
|
let activity_id = self
|
||||||
@@ -323,6 +329,8 @@ impl<'db> RunningBuild<'db> {
|
|||||||
activity
|
activity
|
||||||
.get_mut_activity()
|
.get_mut_activity()
|
||||||
.set_expected(activity_result_set_expected.expected);
|
.set_expected(activity_result_set_expected.expected);
|
||||||
|
|
||||||
|
self.print_current_status();
|
||||||
}
|
}
|
||||||
ActivityResultMessage::PostBuildLogLine(
|
ActivityResultMessage::PostBuildLogLine(
|
||||||
_activity_result_post_build_log_line,
|
_activity_result_post_build_log_line,
|
||||||
@@ -359,9 +367,12 @@ impl<'db> RunningBuild<'db> {
|
|||||||
.get_activity()
|
.get_activity()
|
||||||
.display_name()
|
.display_name()
|
||||||
.expect("Currently we always return a display name.");
|
.expect("Currently we always return a display name.");
|
||||||
let activity_id = activity.get_activity_id();
|
let progress_text = activity.get_activity().get_progress_text();
|
||||||
let parent_id = activity.get_parent_id();
|
let (progress, progress_sep) = match progress_text {
|
||||||
tree += &format!("{leading_bars}{branch} {display_name} {parent_id} {activity_id}\n");
|
Some(text) => (text, " "),
|
||||||
|
None => (Cow::Borrowed(""), ""),
|
||||||
|
};
|
||||||
|
tree += &format!("{leading_bars}{branch} {progress}{progress_sep}{display_name}\n");
|
||||||
}
|
}
|
||||||
if tree.is_empty() {
|
if tree.is_empty() {
|
||||||
println!("No active activities.");
|
println!("No active activities.");
|
||||||
|
|||||||
Reference in New Issue
Block a user