Compare commits
No commits in common. "main" and "v0.1.19" have entirely different histories.
7 changed files with 49 additions and 218 deletions
|
|
@ -1,165 +0,0 @@
|
||||||
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/lines.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="lines_${VER}_amd64"
|
|
||||||
mkdir -p "${DEB_DIR}/DEBIAN" "${DEB_DIR}/usr/bin"
|
|
||||||
cp target/release/lines "${DEB_DIR}/usr/bin/lines"
|
|
||||||
chmod 755 "${DEB_DIR}/usr/bin/lines"
|
|
||||||
|
|
||||||
cat > "${DEB_DIR}/DEBIAN/control" << CONTROL
|
|
||||||
Package: lines
|
|
||||||
Version: ${VER}
|
|
||||||
Section: utils
|
|
||||||
Priority: optional
|
|
||||||
Architecture: amd64
|
|
||||||
Maintainer: janvete <jan.vete@example.com>
|
|
||||||
Description: TUI for running frequently used commands from markdown files
|
|
||||||
CONTROL
|
|
||||||
|
|
||||||
dpkg-deb --build "${DEB_DIR}" "dist/${DEB_DIR}.deb"
|
|
||||||
|
|
||||||
# Linux tarball
|
|
||||||
STAGING=$(mktemp -d)
|
|
||||||
cp target/release/lines "${STAGING}/lines"
|
|
||||||
tar -czf "dist/lines-${VERSION}-linux-amd64.tar.gz" -C "${STAGING}" lines
|
|
||||||
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/lines"
|
|
||||||
|
|
||||||
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 lines ${VERSION}"
|
|
||||||
git push
|
|
||||||
34
.github/workflows/release.yml
vendored
Normal file
34
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-deb:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Install cargo-deb
|
||||||
|
run: cargo install cargo-deb
|
||||||
|
|
||||||
|
- name: Build release binary
|
||||||
|
run: cargo build --release
|
||||||
|
|
||||||
|
- name: Build .deb package
|
||||||
|
run: cargo deb --no-build
|
||||||
|
|
||||||
|
- name: Upload .deb to release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: target/debian/*.deb
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -825,7 +825,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lines"
|
name = "lines"
|
||||||
version = "0.1.21"
|
version = "0.1.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lines"
|
name = "lines"
|
||||||
version = "0.1.21"
|
version = "0.1.19"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["janvete"]
|
authors = ["janvete"]
|
||||||
description = "TUI for running frequently used commands"
|
description = "TUI for running frequently used commands"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://git.janvete.com/seth/lines"
|
repository = "https://github.com/janvete/lines"
|
||||||
homepage = "https://git.janvete.com/seth/lines"
|
homepage = "https://github.com/janvete/lines"
|
||||||
keywords = ["cli", "tui", "ssh", "commands"]
|
keywords = ["cli", "tui", "ssh", "commands"]
|
||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
|
|
||||||
|
|
|
||||||
14
README.md
14
README.md
|
|
@ -7,22 +7,24 @@ A TUI app for quickly running frequently used commands — ideal for SSH scripts
|
||||||
### macOS (Homebrew)
|
### macOS (Homebrew)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew tap janvete/tools https://git.janvete.com/seth/homebrew-tools.git
|
brew tap janvete/tools
|
||||||
brew install lines
|
brew install lines
|
||||||
```
|
```
|
||||||
|
|
||||||
### Debian / Ubuntu (APT)
|
### Debian / Ubuntu (.deb)
|
||||||
|
|
||||||
|
Download the latest `.deb` from the [GitHub Releases](https://github.com/janvete/lines/releases) page and install it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo "deb [trusted=yes] https://git.janvete.com/seth/apt/raw/branch/main ./" | sudo tee /etc/apt/sources.list.d/janvete.list
|
sudo apt install ./lines_*.deb
|
||||||
sudo apt update
|
# or
|
||||||
sudo apt install lines
|
sudo dpkg -i lines_*.deb
|
||||||
```
|
```
|
||||||
|
|
||||||
### From source
|
### From source
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo install --git ssh://git@git-ssh.janvete.com:554/seth/lines
|
cargo install --git https://github.com/janvete/lines
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ pub enum AppEvent {
|
||||||
Tick,
|
Tick,
|
||||||
Key(event::KeyEvent),
|
Key(event::KeyEvent),
|
||||||
Mouse(event::MouseEvent),
|
Mouse(event::MouseEvent),
|
||||||
Paste(String),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll_event(timeout: Duration) -> io::Result<Option<AppEvent>> {
|
pub fn poll_event(timeout: Duration) -> io::Result<Option<AppEvent>> {
|
||||||
|
|
@ -19,7 +18,6 @@ pub fn poll_event(timeout: Duration) -> io::Result<Option<AppEvent>> {
|
||||||
match event::read()? {
|
match event::read()? {
|
||||||
Event::Key(key) => Ok(Some(AppEvent::Key(key))),
|
Event::Key(key) => Ok(Some(AppEvent::Key(key))),
|
||||||
Event::Mouse(mouse) => Ok(Some(AppEvent::Mouse(mouse))),
|
Event::Mouse(mouse) => Ok(Some(AppEvent::Mouse(mouse))),
|
||||||
Event::Paste(text) => Ok(Some(AppEvent::Paste(text))),
|
|
||||||
_ => Ok(Some(AppEvent::Tick)),
|
_ => Ok(Some(AppEvent::Tick)),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -52,7 +50,6 @@ pub fn handle_event(app: &mut App, event: AppEvent) -> bool {
|
||||||
}
|
}
|
||||||
_ => true,
|
_ => true,
|
||||||
},
|
},
|
||||||
AppEvent::Paste(text) => handle_paste_event(app, &text),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,35 +239,6 @@ fn pop_from_active_input(state: &mut CustomState) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_paste_event(app: &mut App, text: &str) -> bool {
|
|
||||||
match app.screen {
|
|
||||||
Screen::Main => true,
|
|
||||||
Screen::Custom => {
|
|
||||||
let Some(state) = app.custom_state.as_mut() else {
|
|
||||||
app.exit_custom();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
match state.focus {
|
|
||||||
CustomFocus::Input => state.command.push_str(text),
|
|
||||||
CustomFocus::PreCommand => state.pre_command.push_str(text),
|
|
||||||
CustomFocus::Lines => {}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
Screen::Search => {
|
|
||||||
let Some(state) = app.search_state.as_mut() else {
|
|
||||||
app.exit_search();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
// Search queries are single-line; keep only the first pasted line.
|
|
||||||
let query = text.lines().next().unwrap_or(text);
|
|
||||||
state.query.push_str(query);
|
|
||||||
app.update_search();
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_search_event(app: &mut App, key: event::KeyEvent) -> bool {
|
fn handle_search_event(app: &mut App, key: event::KeyEvent) -> bool {
|
||||||
let Some(state) = app.search_state.as_mut() else {
|
let Some(state) = app.search_state.as_mut() else {
|
||||||
app.exit_search();
|
app.exit_search();
|
||||||
|
|
|
||||||
14
src/main.rs
14
src/main.rs
|
|
@ -14,9 +14,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{
|
event::{DisableMouseCapture, EnableMouseCapture},
|
||||||
DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture,
|
|
||||||
},
|
|
||||||
execute,
|
execute,
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||||
};
|
};
|
||||||
|
|
@ -56,12 +54,7 @@ fn main() -> io::Result<()> {
|
||||||
|
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
execute!(
|
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
||||||
stdout,
|
|
||||||
EnterAlternateScreen,
|
|
||||||
EnableMouseCapture,
|
|
||||||
EnableBracketedPaste
|
|
||||||
)?;
|
|
||||||
let backend = CrosstermBackend::new(stdout);
|
let backend = CrosstermBackend::new(stdout);
|
||||||
let mut terminal = Terminal::new(backend)?;
|
let mut terminal = Terminal::new(backend)?;
|
||||||
|
|
||||||
|
|
@ -71,8 +64,7 @@ fn main() -> io::Result<()> {
|
||||||
execute!(
|
execute!(
|
||||||
terminal.backend_mut(),
|
terminal.backend_mut(),
|
||||||
LeaveAlternateScreen,
|
LeaveAlternateScreen,
|
||||||
DisableMouseCapture,
|
DisableMouseCapture
|
||||||
DisableBracketedPaste
|
|
||||||
)?;
|
)?;
|
||||||
terminal.show_cursor()?;
|
terminal.show_cursor()?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue