Merge branch 'dev'

This commit is contained in:
Jack Wills
2022-09-27 19:51:08 -04:00
6 changed files with 36 additions and 36 deletions
+10 -16
View File
@@ -1,13 +1,7 @@
<p align="center"> <p align="center">
<img src='./.github/logo.svg' width='100px'/> <img src='./.github/logo.svg' width='100px'/>
</p>
<p align="center">
<h1 align="center">oxker</h1> <h1 align="center">oxker</h1>
</p> <div align="center">A simple tui to view & control docker containers</div>
<p align="center">
A simple tui to view & control docker containers
</p> </p>
<p align="center"> <p align="center">
@@ -22,9 +16,9 @@
## Run via Docker ## Run via Docker
Published on <a href='https://hub.docker.com/r/mrjackwills/oxker' target='_blank' rel='noopener noreferrer'>Docker Hub</a>, with images built for `linux/amd64`, `linux/arm64v8`, and `linux/armv6` Published on <a href='https://hub.docker.com/r/mrjackwills/oxker' target='_blank' rel='noopener noreferrer'>Docker Hub</a>, with images built for `linux/amd64`, `linux/arm64`, and `linux/arm/v6`
`docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro mrjackwills/oxker:latest` `docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro --pull=always mrjackwills/oxker`
## Download & install ## Download & install
@@ -51,12 +45,12 @@ rm oxker_linux_x86_64.tar.gz oxker
In application controls In application controls
| button| result| | button| result|
|--|--| |--|--|
| ```( tab )``` or ```( shift+tab )``` | Change panel, clicking on a panel also changes the selected panel| | ```( tab )``` or ```( shift+tab )``` | change panel, clicking on a panel also changes the selected panel|
| ```( ↑ ↓ )``` or ```( j k )``` or ```(PgUp PgDown)``` or ```(Home End)```| Change selected line in selected panel, mouse scroll also changes selected line | | ```( ↑ ↓ )``` or ```( j k )``` or ```(PgUp PgDown)``` or ```(Home End)```| change selected line in selected panel, mouse scroll also changes selected line |
| ```( enter )```| execute selected docker command| | ```( enter )```| execute selected docker command|
| ```( 1-9 )``` | sort containers by heading, clicking on headings also sorts the selected column | | ```( 1-9 )``` | sort containers by heading, clicking on headings also sorts the selected column |
| ```( 0 )``` | stop sorting | | ```( 0 )``` | stop sorting |
| ```( h )``` | Show help menu | | ```( h )``` | toggle help menu |
| ```( m )``` | toggle mouse capture - if disabled, text on screen can be selected| | ```( m )``` | toggle mouse capture - if disabled, text on screen can be selected|
| ```( q )``` | to quit at any time | | ```( q )``` | to quit at any time |
@@ -65,10 +59,10 @@ Available command line arguments
| argument|result| | argument|result|
|--|--| |--|--|
|```-d [number > 0]```| set the minimum update interval for docker information, in ms, defaults to 1000 (1 second) | |```-d [number > 0]```| set the minimum update interval for docker information, in ms, defaults to 1000 (1 second) |
|```-r```| Show raw logs, by default oxker will remove ANSI formatting (conflicts with -c) | |```-r```| show raw logs, by default oxker will remove ANSI formatting (conflicts with -c) |
|```-c```| Attempt to color the logs (conflicts with -r) | |```-c```| attempt to color the logs (conflicts with -r) |
|```-t```| Remove timestamps from each log entry | |```-t```| remove timestamps from each log entry |
|```-g```| No tui, basically a pointless debugging mode, for now | |```-g```| no tui, basically a pointless debugging mode, for now |
## Build step ## Build step
+4 -6
View File
@@ -1,8 +1,6 @@
<p align="center">
<img src='https://raw.githubusercontent.com/mrjackwills/oxker/main/.github/logo.svg' width='100px'/>
</p>
<p align="center"> <p align="center">
<img src='https://raw.githubusercontent.com/mrjackwills/oxker/main/.github/logo.svg' width='100px'/>
<h1 align="center">oxker</h1> <h1 align="center">oxker</h1>
<div align="center"> <div align="center">
A simple tui to view & control docker containers A simple tui to view & control docker containers
@@ -17,10 +15,10 @@
## Run ## Run
Images built for `linux/amd64`, `linux/arm64v8`, and `linux/armv6` Images built for `linux/amd64`, `linux/arm64`, and `linux/arm/v6`
`docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro mrjackwills/oxker:latest` `docker run --rm -it --volume /var/run/docker.sock:/var/run/docker.sock:ro --pull=always mrjackwills/oxker`
## Help ## Help
visit the<a href="https://github.com/mrjackwills/oxker" target='_blank' rel='noopener noreferrer'> Github repo</a> visit the <a href="https://github.com/mrjackwills/oxker" target='_blank' rel='noopener noreferrer'>Github repo</a>
+5
View File
@@ -230,6 +230,7 @@ main() {
options=( options=(
1 "test" off 1 "test" off
2 "release" off 2 "release" off
3 "build" off
) )
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
exitStatus=$? exitStatus=$?
@@ -250,6 +251,10 @@ main() {
2) 2)
release_flow release_flow
break;; break;;
3)
cargo_build
main
break;;
esac esac
done done
} }
+9 -6
View File
@@ -7,6 +7,11 @@ use tui::{
use super::Header; use super::Header;
const ONE_KB: f64 = 1000.0;
const ONE_MB: f64 = ONE_KB * 1000.0;
const ONE_GB: f64 = ONE_MB * 1000.0;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct StatefulList<T> { pub struct StatefulList<T> {
pub state: ListState, pub state: ListState,
@@ -301,14 +306,12 @@ impl Stats for ByteStats {
// convert from bytes to kB, MB, GB etc // convert from bytes to kB, MB, GB etc
impl fmt::Display for ByteStats { impl fmt::Display for ByteStats {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let one_kb = 1000.0; // TODO these can be consts outside of this definition
let one_mb = one_kb * one_kb;
let one_gb = one_mb * 1000.0;
let as_f64 = self.value as f64; let as_f64 = self.value as f64;
let p = match as_f64 { let p = match as_f64 {
x if x >= one_gb => format!("{y:.2} GB", y = as_f64 / one_gb), x if x >= ONE_GB => format!("{y:.2} GB", y = as_f64 / ONE_GB),
x if x >= one_kb => format!("{y:.2} MB", y = as_f64 / one_mb), x if x >= ONE_MB => format!("{y:.2} MB", y = as_f64 / ONE_MB),
x if x >= one_mb => format!("{y:.2} kB", y = as_f64 / one_kb), x if x >= ONE_KB => format!("{y:.2} kB", y = as_f64 / ONE_KB),
_ => format!("{} B", self.value), _ => format!("{} B", self.value),
}; };
write!(f, "{:>x$}", p, x = f.width().unwrap_or(1)) write!(f, "{:>x$}", p, x = f.width().unwrap_or(1))
+1 -1
View File
@@ -39,7 +39,7 @@ pub enum Header {
Tx, Tx,
} }
/// Convert errors into strings to display /// Convert Header enum into strings to display
impl fmt::Display for Header { impl fmt::Display for Header {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let disp = match self { let disp = match self {
+7 -7
View File
@@ -22,14 +22,14 @@ impl SelectablePanel {
Self::Commands => "", Self::Commands => "",
} }
} }
pub fn next(self) -> Self { pub const fn next(self) -> Self {
match self { match self {
Self::Containers => Self::Commands, Self::Containers => Self::Commands,
Self::Commands => Self::Logs, Self::Commands => Self::Logs,
Self::Logs => Self::Containers, Self::Logs => Self::Containers,
} }
} }
pub fn prev(self) -> Self { pub const fn prev(self) -> Self {
match self { match self {
Self::Containers => Self::Logs, Self::Containers => Self::Logs,
Self::Commands => Self::Containers, Self::Commands => Self::Containers,
@@ -196,7 +196,7 @@ impl GuiState {
} }
} }
/// clear panels hash map, so on resize can fix the sizes for mouse clicks /// Clear panels hash map, so on resize can fix the sizes for mouse clicks
pub fn clear_area_map(&mut self) { pub fn clear_area_map(&mut self) {
self.panel_map.clear(); self.panel_map.clear();
} }
@@ -224,7 +224,7 @@ impl GuiState {
.map(|data| data.0.clone()) .map(|data| data.0.clone())
} }
/// Insert, or updatem header area panel into heading_map /// Insert, or updates header area panel into heading_map
pub fn update_map(&mut self, region: Region, area: Rect) { pub fn update_map(&mut self, region: Region, area: Rect) {
match region { match region {
Region::Header(header) => self Region::Header(header) => self
@@ -258,10 +258,10 @@ impl GuiState {
/// if is_loading, return loading animation frame, else single space /// if is_loading, return loading animation frame, else single space
pub fn get_loading(&mut self) -> String { pub fn get_loading(&mut self) -> String {
if !self.is_loading.is_empty() { if self.is_loading.is_empty() {
self.loading_icon.to_string()
} else {
String::from(" ") String::from(" ")
} else {
self.loading_icon.to_string()
} }
} }