-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
196c005
commit 88d9d8a
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ pub(crate) mod list; | |
pub(crate) mod runner; | ||
pub(crate) mod telemetry; | ||
pub(crate) mod up; | ||
pub(crate) mod watch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use eyre::Result; | ||
use std::time::Duration; | ||
|
||
pub(crate) fn run() -> Result<()> { | ||
crate::runner::run_until_ctrl_c(async { | ||
loop { | ||
// clear the terminal and reset the cursor to the top left | ||
print!("\x1B[2J\x1B[1;1H"); | ||
|
||
let containers = op_composer::Composer::new()? | ||
.list_containers(Some("running")) | ||
.await?; | ||
|
||
let mut table = prettytable::Table::new(); | ||
table.set_titles(prettytable::row!["Name", "Image", "Status", "Up Time"]); | ||
for container in containers { | ||
table.add_row(prettytable::row![ | ||
container | ||
.names | ||
.map(|n| n.join(", ")) | ||
.unwrap_or_else(|| "none".to_string()), | ||
container.image.unwrap_or_else(|| "none".to_string()), | ||
container.status.unwrap_or_else(|| "none".to_string()), | ||
container | ||
.created | ||
.map(|created| humantime::format_duration(Duration::from_secs( | ||
created as u64 | ||
)) | ||
.to_string()) | ||
.unwrap_or_else(|| "unknown".to_string()) | ||
]); | ||
} | ||
table.printstd(); | ||
tokio::time::sleep(Duration::from_secs(2)).await; | ||
} | ||
}) | ||
} |