Skip to content

Commit

Permalink
TestManager: Add flexibility to displayed columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ecpullen committed Mar 1, 2023
1 parent 609fe27 commit dbf1ece
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 311 deletions.
23 changes: 11 additions & 12 deletions cli/src/status.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use anyhow::{Context, Result};
use clap::Parser;
use terminal_size::{Height, Width};
use testsys_model::test_manager::{
CrdState, CrdType, SelectionParams, StatusProgress, TestManager,
};
use testsys_model::test_manager::{CrdState, CrdType, SelectionParams, StatusColumn, TestManager};

/// Check the status of a TestSys object.
#[derive(Debug, Parser)]
Expand All @@ -20,10 +18,6 @@ pub(crate) struct Status {
#[clap(long, short = 'p')]
progress: bool,

/// Include the `Test` status, too. Requires `--progress`
#[clap(long, requires("progress"))]
with_test: bool,

/// Include the time the CRD was last updated
#[clap(long, short = 'u')]
with_time: bool,
Expand Down Expand Up @@ -68,14 +62,19 @@ impl Status {
.await
.context("Unable to get status")?;

if self.with_test {
status.with_progress(StatusProgress::WithTests);
} else if self.progress {
status.with_progress(StatusProgress::Resources);
status.add_column(StatusColumn::name());
status.add_column(StatusColumn::crd_type());
status.add_column(StatusColumn::state());
status.add_column(StatusColumn::passed());
status.add_column(StatusColumn::failed());
status.add_column(StatusColumn::skipped());

if self.progress {
status.add_column(StatusColumn::progress());
}

if self.with_time {
status.with_time();
status.add_column(StatusColumn::last_update());
}

if self.json {
Expand Down
9 changes: 1 addition & 8 deletions model/src/test_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub use error::{Error, Result};
pub use manager::{read_manifest, TestManager};
use serde::{Deserialize, Serialize};
use serde_plain::derive_fromstr_from_deserialize;
pub use status::StatusSnapshot;
pub use status::{StatusColumn, StatusSnapshot};
use std::collections::HashMap;

mod delete;
Expand Down Expand Up @@ -85,10 +85,3 @@ pub enum ResourceState {
}

derive_fromstr_from_deserialize!(ResourceState);

/// `StatusProgress` represents whether a `Test`'s `other_info` should be included or not.
#[derive(Debug)]
pub enum StatusProgress {
WithTests,
Resources,
}
Loading

0 comments on commit dbf1ece

Please sign in to comment.