From ba4b8ab7f1562080e8437077d350a061d1b4ea7e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Aillet Date: Mon, 25 Dec 2023 23:28:53 +0100 Subject: [PATCH] :sparkles: update doc and help --- Makefile | 7 ++-- README.md | 11 +++++-- doc/Dockerfile | 62 ++++++++++++++++++++++++++++++++++++ doc/docker-compose.yaml | 1 + doc/preview.tape | 9 +++--- src/components/containers.rs | 4 +++ src/components/images.rs | 11 +++++-- src/components/networks.rs | 11 +++++-- src/components/volumes.rs | 11 +++++-- src/utils.rs | 3 -- 10 files changed, 112 insertions(+), 18 deletions(-) create mode 100644 doc/Dockerfile diff --git a/Makefile b/Makefile index 9c61e5f..5f05e47 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,11 @@ default: .PHONY: preview preview: doc/preview.gif -doc/preview.gif: doc/preview.tape doc/docker-compose.yaml target/release/doggy - docker compose -f doc/docker-compose.yaml run vhs ./doc/preview.tape +doc/preview.gif: doc/preview.tape doc/docker-compose.yaml target/x86_64-unknown-linux-gnu/release/doggy + docker compose -f doc/docker-compose.yaml run --build vhs ./doc/preview.tape + +target/x86_64-unknown-linux-gnu/release/doggy: src/*.rs src/components/*.rs + RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-gnu .PHONY: tracing tracing: diff --git a/README.md b/README.md index 46d6ab4..2390945 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,14 @@ You can download one of the binary from the release page ## Usage +- Display help screen: `?` - Change view: `:` and resource name (`containers`, `images`, `networks`, `volumes`) -- Show/hide stopped containers: `a` -- Launch `/bin/bash` in the container: `s` -- Launch a custom command in the container: `S` +- Container view: + - Show/hide stopped containers: `a` + - Launch `/bin/bash` in the container: `s` + - Launch a custom command in the container: `S` + - Show container logs: `l` +- Sort by columns: `F[1234]` - Inspect resource: `i` - Delete a resource: `Ctrl+d` - Browse lists: @@ -42,6 +46,7 @@ You can download one of the binary from the release page - [x] Display the stopped containers - [ ] Filter the container list - [x] Inspect containers +- [x] View container logs - [x] Exec `/bin/bash` in a container - [x] Delete containers (running or stopped) - [x] List images diff --git a/doc/Dockerfile b/doc/Dockerfile new file mode 100644 index 0000000..5334e9e --- /dev/null +++ b/doc/Dockerfile @@ -0,0 +1,62 @@ +FROM tsl0922/ttyd:alpine as ttyd +FROM alpine:latest as fontcollector + +# Install Fonts +RUN apk add --no-cache \ + --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \ + --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \ + --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing \ + font-adobe-source-code-pro font-source-code-pro-nerd \ + font-dejavu font-dejavu-sans-mono-nerd \ + font-fira-code font-fira-code-nerd \ + font-hack font-hack-nerd \ + font-ibm-plex-mono-nerd \ + font-inconsolata font-inconsolata-nerd \ + font-jetbrains-mono font-jetbrains-mono-nerd \ + font-liberation font-liberation-mono-nerd \ + font-noto \ + font-roboto-mono \ + font-ubuntu font-ubuntu-mono-nerd \ + font-noto-emoji + +FROM debian:unstable-slim + +RUN apt-get update + +# Add fonts +COPY --from=fontcollector /usr/share/fonts/ /usr/share/fonts + +# Install latest ttyd +COPY --from=ttyd /usr/bin/ttyd /usr/bin/ttyd + +# Expose port +EXPOSE 1976 + +# Create volume +VOLUME /vhs +WORKDIR /vhs + +# Install Dependencies +RUN apt-get -y install ffmpeg chromium bash +RUN apt-get -y install curl + +# Create user +RUN useradd -u 1976 -U -s /bin/false vhs +# Mimic alpine default color option +RUN echo 'alias ls="ls --color"' >> ~/.bashrc +# Install +RUN curl -L https://github.com/charmbracelet/vhs/releases/download/v0.7.1/vhs_0.7.1_amd64.deb -o /tmp/vhs_0.7.1_amd64.deb +RUN dpkg -i /tmp/vhs_0.7.1_amd64.deb +RUN rm /tmp/vhs_0.7.1_amd64.deb +#COPY vhs /usr/bin/ + +ENV VHS_PORT "1976" +ENV VHS_HOST "0.0.0.0" +ENV VHS_GID "1976" +ENV VHS_UID "1976" +ENV VHS_KEY_PATH "/vhs/vhs" +ENV VHS_AUTHORIZED_KEYS_PATH "" +ENV VHS_NO_SANDBOX "true" + +ENTRYPOINT ["/usr/bin/vhs"] + diff --git a/doc/docker-compose.yaml b/doc/docker-compose.yaml index 7e55c49..eafb38c 100644 --- a/doc/docker-compose.yaml +++ b/doc/docker-compose.yaml @@ -2,6 +2,7 @@ version: "3.8" services: vhs: image: ghcr.io/charmbracelet/vhs + build: . working_dir: /vhs volumes: - ../:/vhs diff --git a/doc/preview.tape b/doc/preview.tape index e0fb7b7..4963280 100644 --- a/doc/preview.tape +++ b/doc/preview.tape @@ -9,6 +9,7 @@ Set TypingSpeed 100ms # Type a command in the terminal. Type "./target/release/doggy" +# Type "./target/x86_64-unknown-linux-gnu/release/doggy" Enter @@ -49,10 +50,10 @@ Type "j" Sleep 200ms Type "j" Sleep 200ms -Ctrl+d -Sleep 1s -Enter -Sleep 2s +#Ctrl+d +#Sleep 1s +#Enter +#Sleep 2s Type "i" Sleep 1s PageDown diff --git a/src/components/containers.rs b/src/components/containers.rs index f66199b..ab50746 100644 --- a/src/components/containers.rs +++ b/src/components/containers.rs @@ -426,6 +426,10 @@ impl Component for Containers { ("l", "Logs"), ("s", "Execute '/bin/bash' in container"), ("S", "Execute custom command"), + ("F1", "Sort by container id"), + ("F2", "Sort by container name"), + ("F3", "Sort by image name"), + ("F4", "Sort by status"), ]) } diff --git a/src/components/images.rs b/src/components/images.rs index 222d4fd..8cfb40b 100644 --- a/src/components/images.rs +++ b/src/components/images.rs @@ -11,7 +11,7 @@ use tokio::sync::mpsc::UnboundedSender; use crate::action::Action; use crate::components::Component; use crate::runtime::{delete_image, get_image, list_images}; -use crate::utils::{centered_rect, table, COMMON_LIST_BINDINGS}; +use crate::utils::{centered_rect, table}; const IMAGE_CONSTRAINTS: [Constraint; 4] = [ Constraint::Max(15), @@ -238,6 +238,13 @@ impl Component for Images { } fn get_bindings(&self) -> Option<&[(&str, &str)]> { - Some(&COMMON_LIST_BINDINGS) + Some(&[ + ("ctrl+d", "Delete"), + ("i", "Inspect/View details"), + ("F1", "Sort by image id"), + ("F2", "Sort by image name"), + ("F3", "Sort by image size"), + ("F4", "Sort by image age"), + ]) } } diff --git a/src/components/networks.rs b/src/components/networks.rs index ad727ea..410559d 100644 --- a/src/components/networks.rs +++ b/src/components/networks.rs @@ -11,7 +11,7 @@ use tokio::sync::mpsc::UnboundedSender; use crate::action::Action; use crate::components::Component; use crate::runtime::{delete_network, get_network, list_networks}; -use crate::utils::{centered_rect, table, COMMON_LIST_BINDINGS}; +use crate::utils::{centered_rect, table}; const NETWORK_CONSTRAINTS: [Constraint; 4] = [ Constraint::Max(15), @@ -243,6 +243,13 @@ impl Component for Networks { } fn get_bindings(&self) -> Option<&[(&str, &str)]> { - Some(&COMMON_LIST_BINDINGS) + Some(&[ + ("ctrl+d", "Delete"), + ("i", "Inspect/View details"), + ("F1", "Sort by network id"), + ("F2", "Sort by network name"), + ("F3", "Sort by network driver"), + ("F4", "Sort by image age"), + ]) } } diff --git a/src/components/volumes.rs b/src/components/volumes.rs index 011639c..4002319 100644 --- a/src/components/volumes.rs +++ b/src/components/volumes.rs @@ -11,7 +11,7 @@ use tokio::sync::mpsc::UnboundedSender; use crate::action::Action; use crate::components::Component; use crate::runtime::{delete_volume, get_volume, list_volumes}; -use crate::utils::{centered_rect, table, COMMON_LIST_BINDINGS}; +use crate::utils::{centered_rect, table}; const VOLUME_CONSTRAINTS: [Constraint; 4] = [ Constraint::Max(15), @@ -237,6 +237,13 @@ impl Component for Volumes { } fn get_bindings(&self) -> Option<&[(&str, &str)]> { - Some(&COMMON_LIST_BINDINGS) + Some(&[ + ("ctrl+d", "Delete"), + ("i", "Inspect/View details"), + ("F1", "Sort by volume id"), + ("F2", "Sort by volume driver"), + ("F3", "Sort by volume size"), + ("F4", "Sort by volume age"), + ]) } } diff --git a/src/utils.rs b/src/utils.rs index e5e73e6..1c21018 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -45,9 +45,6 @@ const NAVIGATION_BINDINGS: [(&str, &str); 4] = [ ("PageDown", "Page down"), ]; -pub(crate) const COMMON_LIST_BINDINGS: [(&str, &str); 2] = - [("ctrl+d", "Delete"), ("i", "Inspect/View details")]; - fn project_directory() -> Option { ProjectDirs::from("org", "pyaillet", env!("CARGO_PKG_NAME")) }