Skip to content

Commit 016ad61

Browse files
author
Antoine Busch
committed
Make docker info view a bit prettier
1 parent 8c8f3ac commit 016ad61

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

src/views/docker_info.rs

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use shiplift::rep::Info;
44
use termion::event::Key;
55
use tui::{
66
layout::Rect,
7+
style::{Color, Modifier, Style},
78
widgets::{Block, Borders, Paragraph, Text, Widget},
89
Frame,
910
};
@@ -33,12 +34,49 @@ impl View for DockerInfo {
3334
}
3435

3536
fn draw(&self, t: &mut Frame<Backend>, rect: Rect) {
36-
let display_string = if let Some(ref info) = self.info {
37-
format!("{:#?}", info)
37+
let text = if let Some(ref info) = self.info {
38+
vec![
39+
Text::styled(
40+
"Host details\n",
41+
Style::default().modifier(Modifier::BOLD).fg(Color::Blue),
42+
),
43+
Text::styled(format!("Hostname: {}\n", info.name), Style::default()),
44+
Text::styled(
45+
format!("OS Information: {}\n", info.operating_system),
46+
Style::default(),
47+
),
48+
Text::styled(
49+
format!("Kernel Version: {}\n", info.kernel_version),
50+
Style::default(),
51+
),
52+
Text::styled(
53+
format!("Total CPU: {}\n", info.n_cpu),
54+
Style::default(),
55+
),
56+
Text::styled(
57+
format!("Total Memory: {}\n", info.mem_total),
58+
Style::default(),
59+
),
60+
Text::raw("\n"),
61+
Text::styled(
62+
"Engine details\n",
63+
Style::default().modifier(Modifier::BOLD).fg(Color::Blue),
64+
),
65+
Text::styled(
66+
format!("Root Directory: {}\n", info.docker_root_dir),
67+
Style::default(),
68+
),
69+
Text::styled(
70+
format!("Storage Driver: {}\n", info.driver),
71+
Style::default(),
72+
),
73+
]
3874
} else {
39-
"Could not retrieve information from the Docker daemon.".to_string()
75+
vec![Text::styled(
76+
"Could not retrieve information from the Docker daemon.".to_string(),
77+
Style::default(),
78+
)]
4079
};
41-
let text = vec![Text::raw(display_string)];
4280

4381
Paragraph::new(text.iter())
4482
.block(Block::default().borders(Borders::ALL))

0 commit comments

Comments
 (0)