Compare commits
21 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c96818e97 | |||
| ef49632ef0 | |||
| 62c4c7c6cb | |||
| dfd7b856a4 | |||
| b80043b5da | |||
| 0e9b73d396 | |||
| 3349ff8ba0 | |||
| e78e71c395 | |||
| ed129e8cc6 | |||
| 732577da4c | |||
| 445e40ba27 | |||
| 31dc7d189b | |||
| 58523a2ec8 | |||
| 640db18d25 | |||
| 643590086c | |||
| 0a19875717 | |||
| 9d001823d5 | |||
| da3e723a21 | |||
| aefaffbcbf | |||
| ae6639ed2d | |||
| b2c86c00f3 |
6 changed files with 235 additions and 112 deletions
165
.forgejo/workflows/release.yml
Normal file
165
.forgejo/workflows/release.yml
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: rust:bookworm
|
||||||
|
volumes:
|
||||||
|
- /opt/runner/keys:/keys:ro
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install tools
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y dpkg-dev git curl openssh-client
|
||||||
|
|
||||||
|
- name: Setup SSH
|
||||||
|
run: |
|
||||||
|
test -r /keys/forgejo_runner || { echo "Deploy key /keys/forgejo_runner chybi"; exit 1; }
|
||||||
|
install -m 600 /keys/forgejo_runner /tmp/forgejo_runner
|
||||||
|
echo "GIT_SSH_COMMAND=ssh -p 554 -i /tmp/forgejo_runner -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Checkout source
|
||||||
|
run: |
|
||||||
|
git clone ssh://git@git-ssh.janvete.com:554/seth/lview.git src
|
||||||
|
cd src
|
||||||
|
git checkout "${{ github.ref_name }}"
|
||||||
|
|
||||||
|
- name: Build Linux release binary and .deb
|
||||||
|
working-directory: src
|
||||||
|
run: |
|
||||||
|
VERSION=${{ github.ref_name }}
|
||||||
|
VER=${VERSION#v}
|
||||||
|
mkdir -p dist
|
||||||
|
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
# .deb package
|
||||||
|
DEB_DIR="lview_${VER}_amd64"
|
||||||
|
mkdir -p "${DEB_DIR}/DEBIAN" "${DEB_DIR}/usr/bin"
|
||||||
|
cp target/release/lview "${DEB_DIR}/usr/bin/lview"
|
||||||
|
chmod 755 "${DEB_DIR}/usr/bin/lview"
|
||||||
|
|
||||||
|
cat > "${DEB_DIR}/DEBIAN/control" << CONTROL
|
||||||
|
Package: lview
|
||||||
|
Version: ${VER}
|
||||||
|
Section: utils
|
||||||
|
Priority: optional
|
||||||
|
Architecture: amd64
|
||||||
|
Maintainer: janvete <jan.vete@example.com>
|
||||||
|
Description: TUI for viewing remote logs over SSH
|
||||||
|
CONTROL
|
||||||
|
|
||||||
|
dpkg-deb --build "${DEB_DIR}" "dist/${DEB_DIR}.deb"
|
||||||
|
|
||||||
|
# Linux tarball
|
||||||
|
STAGING=$(mktemp -d)
|
||||||
|
cp target/release/lview "${STAGING}/lview"
|
||||||
|
tar -czf "dist/lview-${VERSION}-linux-amd64.tar.gz" -C "${STAGING}" lview
|
||||||
|
rm -rf "${STAGING}"
|
||||||
|
|
||||||
|
- name: Print checksums
|
||||||
|
working-directory: src
|
||||||
|
run: |
|
||||||
|
echo "=== SHA256 checksums ==="
|
||||||
|
sha256sum dist/*
|
||||||
|
|
||||||
|
- name: Create Forgejo Release
|
||||||
|
working-directory: src
|
||||||
|
env:
|
||||||
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
FORGEJO_URL: https://git.janvete.com
|
||||||
|
run: |
|
||||||
|
VERSION=${{ github.ref_name }}
|
||||||
|
API="${FORGEJO_URL}/api/v1/repos/seth/lview"
|
||||||
|
|
||||||
|
RELEASE_JSON=$(curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-X POST \
|
||||||
|
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"${VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
"${API}/releases")
|
||||||
|
|
||||||
|
echo "Create release response: ${RELEASE_JSON}"
|
||||||
|
RELEASE_ID=$(echo "${RELEASE_JSON}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
|
|
||||||
|
if [ -z "${RELEASE_ID}" ]; then
|
||||||
|
echo "Release may already exist, fetching existing release..."
|
||||||
|
EXISTING=$(curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
"${API}/releases/tags/${VERSION}")
|
||||||
|
echo "Existing release response: ${EXISTING}"
|
||||||
|
RELEASE_ID=$(echo "${EXISTING}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${RELEASE_ID}" ]; then
|
||||||
|
echo "Failed to create or fetch release"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for ARCHIVE in dist/*; do
|
||||||
|
[ -e "${ARCHIVE}" ] || continue
|
||||||
|
NAME=$(basename "${ARCHIVE}")
|
||||||
|
case "${NAME}" in
|
||||||
|
*.tar.gz) CONTENT_TYPE="application/gzip" ;;
|
||||||
|
*.deb) CONTENT_TYPE="application/vnd.debian.binary-package" ;;
|
||||||
|
*) CONTENT_TYPE="application/octet-stream" ;;
|
||||||
|
esac
|
||||||
|
curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-H "Content-Type: ${CONTENT_TYPE}" \
|
||||||
|
--data-binary "@${ARCHIVE}" \
|
||||||
|
"${API}/releases/${RELEASE_ID}/assets?name=${NAME}"
|
||||||
|
echo "Uploaded ${NAME}"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Update APT repository
|
||||||
|
working-directory: src
|
||||||
|
run: |
|
||||||
|
VERSION=${{ github.ref_name }}
|
||||||
|
|
||||||
|
git clone ssh://git@git-ssh.janvete.com:554/seth/apt.git apt-repo
|
||||||
|
cp dist/*.deb apt-repo/
|
||||||
|
|
||||||
|
cd apt-repo
|
||||||
|
|
||||||
|
# Remove any corrupted .deb files left from previous failed runs
|
||||||
|
for f in *.deb; do
|
||||||
|
[ -e "$f" ] || continue
|
||||||
|
if ! dpkg-deb -I "$f" >/dev/null 2>&1; then
|
||||||
|
echo "Removing corrupted package: $f"
|
||||||
|
rm -f "$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
dpkg-scanpackages . > Packages
|
||||||
|
gzip -k -f Packages
|
||||||
|
|
||||||
|
cat > Release << RELEASE
|
||||||
|
Origin: janvete
|
||||||
|
Label: janvete
|
||||||
|
Suite: stable
|
||||||
|
Codename: stable
|
||||||
|
Version: 1.0
|
||||||
|
Architectures: amd64
|
||||||
|
Components: main
|
||||||
|
Description: janvete tools APT repository
|
||||||
|
Date: $(date -Ru)
|
||||||
|
RELEASE
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "SHA256:"
|
||||||
|
for f in Packages Packages.gz *.deb; do
|
||||||
|
[ -e "$f" ] || continue
|
||||||
|
printf " %s %16d %s\n" "$(sha256sum "$f" | cut -d' ' -f1)" "$(stat -c%s "$f")" "$f"
|
||||||
|
done
|
||||||
|
} >> Release
|
||||||
|
|
||||||
|
git config user.email "forgejo-actions[bot]@janvete.com"
|
||||||
|
git config user.name "forgejo-actions[bot]"
|
||||||
|
git add -A
|
||||||
|
git commit -m "chore: add lview ${VERSION}"
|
||||||
|
git push
|
||||||
61
.github/workflows/release.yml
vendored
61
.github/workflows/release.yml
vendored
|
|
@ -1,61 +0,0 @@
|
||||||
name: Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-macos:
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
|
||||||
- run: cargo build --release
|
|
||||||
- run: cargo test --release
|
|
||||||
- run: cargo clippy --release -- -D warnings
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: lview-macos
|
|
||||||
path: target/release/lview
|
|
||||||
|
|
||||||
build-linux:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
|
||||||
- run: cargo install cargo-deb
|
|
||||||
- run: cargo build --release
|
|
||||||
- run: cargo test --release
|
|
||||||
- run: cargo clippy --release -- -D warnings
|
|
||||||
- run: cargo deb
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: lview-linux
|
|
||||||
path: |
|
|
||||||
target/release/lview
|
|
||||||
target/debian/*.deb
|
|
||||||
|
|
||||||
release:
|
|
||||||
needs: [build-macos, build-linux]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: lview-macos
|
|
||||||
path: artifacts/macos
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: lview-linux
|
|
||||||
path: artifacts/linux
|
|
||||||
- name: Create Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
artifacts/macos/lview
|
|
||||||
artifacts/linux/lview
|
|
||||||
artifacts/linux/*.deb
|
|
||||||
generate_release_notes: true
|
|
||||||
|
|
@ -5,8 +5,8 @@ edition = "2024"
|
||||||
authors = ["janvete"]
|
authors = ["janvete"]
|
||||||
description = "TUI for viewing remote logs over SSH"
|
description = "TUI for viewing remote logs over SSH"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/janvete/lview"
|
repository = "https://git.janvete.com/seth/lview"
|
||||||
homepage = "https://github.com/janvete/lview"
|
homepage = "https://git.janvete.com/seth/lview"
|
||||||
keywords = ["cli", "tui", "ssh", "logs", "docker"]
|
keywords = ["cli", "tui", "ssh", "logs", "docker"]
|
||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
class Lview < Formula
|
class Lview < Formula
|
||||||
desc "TUI for viewing remote logs over SSH"
|
desc "TUI for viewing remote logs over SSH"
|
||||||
homepage "https://github.com/janvete/lview"
|
homepage "https://github.com/janvete/lview"
|
||||||
url "https://github.com/janvete/lview/archive/refs/tags/v0.1.5.tar.gz"
|
url "https://github.com/janvete/lview/archive/refs/tags/v0.1.7.tar.gz"
|
||||||
sha256 "ce8fc09aaf4245cf637127ef945e43dbad085652059012018b945507ceaa2ee3"
|
sha256 "7bb92852698486571a5c31158f64b398d123d3c7ebb1982733c43e0e1c84209a"
|
||||||
license "MIT"
|
license "MIT"
|
||||||
head "https://github.com/janvete/lview.git", branch: "master"
|
head "https://github.com/janvete/lview.git", branch: "master"
|
||||||
|
|
||||||
|
|
|
||||||
68
README.md
68
README.md
|
|
@ -1,68 +1,66 @@
|
||||||
# lview
|
# lview
|
||||||
|
|
||||||
TUI pro prohlížení logů na vzdálených Linux strojích přes SSH. Automaticky detekuje systémové logy, Docker kontejnery, `/opt` aplikace a systemd journal.
|
A TUI for viewing logs on remote Linux machines over SSH. It automatically detects system logs, Docker containers, `/opt` applications, and the systemd journal.
|
||||||
|
|
||||||
## Instalace
|
## Installation
|
||||||
|
|
||||||
### macOS (Homebrew)
|
### macOS (Homebrew)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew tap janvete/tools
|
brew tap janvete/tools https://git.janvete.com/seth/homebrew-tools.git
|
||||||
brew install lview
|
brew install lview
|
||||||
```
|
```
|
||||||
|
|
||||||
### Debian / Ubuntu (.deb)
|
### Debian / Ubuntu (APT)
|
||||||
|
|
||||||
Stáhněte si nejnovější `.deb` z [GitHub Releases](https://github.com/janvete/lview/releases) a nainstalujte:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install ./lview_*.deb
|
echo "deb [trusted=yes] https://git.janvete.com/seth/apt/raw/branch/main ./" | sudo tee /etc/apt/sources.list.d/janvete.list
|
||||||
# nebo
|
sudo apt update
|
||||||
sudo dpkg -i ./lview_*.deb
|
sudo apt install lview
|
||||||
```
|
```
|
||||||
|
|
||||||
### Ze zdroje
|
### From source
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo install --git https://github.com/janvete/lview
|
cargo install --git ssh://git@git-ssh.janvete.com:554/seth/lview
|
||||||
```
|
```
|
||||||
|
|
||||||
## Použití
|
## Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lview ssh -p22 root@192.168.53.3
|
lview ssh -p22 root@192.168.53.3
|
||||||
```
|
```
|
||||||
|
|
||||||
Všechny argumenty za `ssh` jsou předány přímo systémovému `ssh` příkazu, takže se použije vaše `~/.ssh/config`, SSH agent a klíče.
|
All arguments after `ssh` are passed directly to the system `ssh` command, so your `~/.ssh/config`, SSH agent, and keys are used automatically.
|
||||||
|
|
||||||
## Ovládání
|
## Controls
|
||||||
|
|
||||||
### Výběr logu
|
### Log picker
|
||||||
|
|
||||||
| Klávesa | Akce |
|
| Key | Action |
|
||||||
|---------|------|
|
|-----|--------|
|
||||||
| `j` / `k` nebo `↓` / `↑` | pohyb v seznamu |
|
| `j` / `k` or `↓` / `↑` | move through the list |
|
||||||
| `Enter` | otevřít vybraný log |
|
| `Enter` | open the selected log |
|
||||||
| `/` | fuzzy filtrování seznamu logů |
|
| `/` | fuzzy filter the log list |
|
||||||
| `r` | znovu načíst seznam logů |
|
| `r` | reload the log list |
|
||||||
| `q` | ukončit |
|
| `q` | quit |
|
||||||
|
|
||||||
### Prohlížeč logu
|
### Log viewer
|
||||||
|
|
||||||
| Klávesa | Akce |
|
| Key | Action |
|
||||||
|---------|------|
|
|-----|--------|
|
||||||
| `j` / `k` nebo `↓` / `↑` | scroll |
|
| `j` / `k` or `↓` / `↑` | scroll |
|
||||||
| `Ctrl+d` / `Ctrl+u` | scroll o 10 řádků |
|
| `Ctrl+d` / `Ctrl+u` | scroll by 10 lines |
|
||||||
| `g` / `G` | začátek / konec |
|
| `g` / `G` | jump to top / bottom |
|
||||||
| `l` nebo `mezerník` | zapnout/vypnout živý náhled |
|
| `l` or `space` | toggle live preview |
|
||||||
| `/` | vyhledávání v logu (regex, case-insensitive) |
|
| `/` | search in the log (regex, case-insensitive) |
|
||||||
| `n` / `N` | další / předchozí výskyt |
|
| `n` / `N` | next / previous match |
|
||||||
| `s` | uložit aktuální buffer do `/tmp` |
|
| `s` | save the current buffer to `/tmp` |
|
||||||
| `q` nebo `Esc` | zpět do výběru |
|
| `q` or `Esc` | back to the picker |
|
||||||
|
|
||||||
## Konfigurace
|
## Configuration
|
||||||
|
|
||||||
Vytvořte `~/.config/lview/config.toml`:
|
Create `~/.config/lview/config.toml`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
ssh_command = "ssh"
|
ssh_command = "ssh"
|
||||||
|
|
|
||||||
45
src/ui.rs
45
src/ui.rs
|
|
@ -101,7 +101,16 @@ fn draw_preview(f: &mut Frame, app: &App, area: ratatui::layout::Rect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_log_buffer(f: &mut Frame, viewer: &LogViewer, area: ratatui::layout::Rect) {
|
fn draw_log_buffer(f: &mut Frame, viewer: &LogViewer, area: ratatui::layout::Rect) {
|
||||||
let title = format!(" {} — {} ", viewer.source, if viewer.live { "LIVE" } else { "PAUSED" });
|
let live_style = if viewer.live {
|
||||||
|
Style::default().fg(Color::Green).add_modifier(Modifier::BOLD)
|
||||||
|
} else {
|
||||||
|
Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)
|
||||||
|
};
|
||||||
|
let title = Line::from(vec![
|
||||||
|
Span::raw(format!(" {} — ", viewer.source)),
|
||||||
|
Span::styled(if viewer.live { "LIVE" } else { "PAUSED" }, live_style),
|
||||||
|
Span::raw(" "),
|
||||||
|
]);
|
||||||
let visible = viewer.visible_lines();
|
let visible = viewer.visible_lines();
|
||||||
|
|
||||||
// Compute the viewport offset so the current line stays in view.
|
// Compute the viewport offset so the current line stays in view.
|
||||||
|
|
@ -140,7 +149,12 @@ fn draw_log_buffer(f: &mut Frame, viewer: &LogViewer, area: ratatui::layout::Rec
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let paragraph = Paragraph::new(Text::from(lines))
|
let paragraph = Paragraph::new(Text::from(lines))
|
||||||
.block(default_block(&title))
|
.block(
|
||||||
|
Block::default()
|
||||||
|
.title(title)
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_style(Style::default().fg(Color::DarkGray)),
|
||||||
|
)
|
||||||
.wrap(Wrap { trim: false })
|
.wrap(Wrap { trim: false })
|
||||||
.scroll((scroll_offset as u16, 0));
|
.scroll((scroll_offset as u16, 0));
|
||||||
f.render_widget(paragraph, area);
|
f.render_widget(paragraph, area);
|
||||||
|
|
@ -165,17 +179,24 @@ fn draw_status(f: &mut Frame, app: &App, area: ratatui::layout::Rect) {
|
||||||
|
|
||||||
fn draw_viewer_status(f: &mut Frame, app: &App, area: ratatui::layout::Rect) {
|
fn draw_viewer_status(f: &mut Frame, app: &App, area: ratatui::layout::Rect) {
|
||||||
let help = "j/k: scroll | g/G: top/bottom | l/Space: live | /: search | n/N: next/prev | s: save | q: back";
|
let help = "j/k: scroll | g/G: top/bottom | l/Space: live | /: search | n/N: next/prev | s: save | q: back";
|
||||||
let text = match (&app.viewer, &app.message) {
|
let lines = match (&app.viewer, &app.message) {
|
||||||
(Some(v), None) => format!(
|
(Some(v), None) => {
|
||||||
"{} | lines: {} | scroll: {} | {}",
|
let live_style = if v.live {
|
||||||
if v.live { "LIVE" } else { "PAUSED" },
|
Style::default().fg(Color::Green).add_modifier(Modifier::BOLD)
|
||||||
v.buffer.len(),
|
} else {
|
||||||
v.scroll,
|
Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)
|
||||||
help
|
|
||||||
),
|
|
||||||
_ => help.to_string(),
|
|
||||||
};
|
};
|
||||||
let paragraph = Paragraph::new(Text::from(text)).style(Style::default().fg(Color::Gray));
|
Line::from(vec![
|
||||||
|
Span::styled(if v.live { "LIVE" } else { "PAUSED" }, live_style),
|
||||||
|
Span::styled(
|
||||||
|
format!(" | lines: {} | scroll: {} | {}", v.buffer.len(), v.scroll, help),
|
||||||
|
Style::default().fg(Color::Gray),
|
||||||
|
),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
_ => Line::from(Span::styled(help, Style::default().fg(Color::Gray))),
|
||||||
|
};
|
||||||
|
let paragraph = Paragraph::new(Text::from(lines));
|
||||||
f.render_widget(paragraph, area);
|
f.render_widget(paragraph, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue