1 Commits

Author SHA1 Message Date
dependabot[bot]
ca7bfcaa70 Bump actions/cache from 3 to 4
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-09 03:33:40 +00:00
7 changed files with 25 additions and 98 deletions

View File

@@ -21,13 +21,13 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y figlet run: sudo apt-get update && sudo apt-get install -y figlet
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/registry path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index - name: Cache cargo index
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/git path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}

View File

@@ -24,19 +24,19 @@ jobs:
components: rustfmt, clippy components: rustfmt, clippy
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/registry path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index - name: Cache cargo index
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/git path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build - name: Cache cargo build
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: target path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
@@ -77,19 +77,19 @@ jobs:
run: brew install figlet run: brew install figlet
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/registry path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index - name: Cache cargo index
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/git path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build - name: Cache cargo build
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: target path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
@@ -128,19 +128,19 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y musl-tools run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/registry path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index - name: Cache cargo index
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/git path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build - name: Cache cargo build
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: target path: target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

View File

@@ -5,9 +5,6 @@ on:
tags: tags:
- 'v*.*.*' - 'v*.*.*'
permissions:
contents: write
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
@@ -123,19 +120,19 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y musl-tools run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/registry path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index - name: Cache cargo index
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cargo/git path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build - name: Cache cargo build
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: target path: target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-release-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-release-${{ hashFiles('**/Cargo.lock') }}
@@ -151,14 +148,11 @@ jobs:
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
run: strip target/${{ matrix.target }}/release/piglet run: strip target/${{ matrix.target }}/release/piglet
- name: Rename binary
run: |
cp target/${{ matrix.target }}/release/piglet piglet-${{ matrix.target }}
- name: Upload release binary - name: Upload release binary
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
with: with:
files: piglet-${{ matrix.target }} files: target/${{ matrix.target }}/release/piglet
name: piglet-${{ matrix.target }}
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -21,8 +21,8 @@ palette = "0.7"
# Terminal manipulation # Terminal manipulation
crossterm = "0.27" crossterm = "0.27"
# Async runtime (for timing and signal handling) # Async runtime (for timing)
tokio = { version = "1.35", features = ["time", "rt-multi-thread", "macros", "signal", "sync"] } tokio = { version = "1.35", features = ["time", "rt-multi-thread", "macros"] }
# Process execution # Process execution
which = "5.0" which = "5.0"

View File

@@ -43,7 +43,7 @@ impl AnimationEngine {
self self
} }
pub async fn run(&self, terminal: &mut TerminalManager) -> Result<bool> { pub async fn run(&self, terminal: &mut TerminalManager) -> Result<()> {
let renderer = renderer::Renderer::new( let renderer = renderer::Renderer::new(
&self.ascii_art, &self.ascii_art,
self.duration_ms, self.duration_ms,

View File

@@ -2,12 +2,6 @@ use crate::animation::{easing::EasingFunction, effects::Effect, timeline::Timeli
use crate::color::{apply, ColorEngine}; use crate::color::{apply, ColorEngine};
use crate::utils::{ansi, ascii::AsciiArt, terminal::TerminalManager}; use crate::utils::{ansi, ascii::AsciiArt, terminal::TerminalManager};
use anyhow::Result; use anyhow::Result;
use crossterm::event::{self, Event, KeyCode, KeyModifiers};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use std::time::Duration;
use tokio::time::sleep; use tokio::time::sleep;
pub struct Renderer<'a> { pub struct Renderer<'a> {
@@ -36,52 +30,17 @@ impl<'a> Renderer<'a> {
} }
} }
pub async fn render(&self, terminal: &mut TerminalManager) -> Result<bool> { pub async fn render(&self, terminal: &mut TerminalManager) -> Result<()> {
let mut timeline = Timeline::new(self.timeline.duration_ms(), self.timeline.fps()); let mut timeline = Timeline::new(self.timeline.duration_ms(), self.timeline.fps());
timeline.start(); timeline.start();
// Spawn background thread to listen for exit keys
let should_exit = Arc::new(AtomicBool::new(false));
let should_exit_clone = should_exit.clone();
std::thread::spawn(move || loop {
if let Ok(true) = event::poll(Duration::from_millis(100)) {
if let Ok(Event::Key(key)) = event::read() {
match key.code {
KeyCode::Char('q') | KeyCode::Esc => {
should_exit_clone.store(true, Ordering::Relaxed);
break;
}
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
should_exit_clone.store(true, Ordering::Relaxed);
break;
}
_ => {}
}
}
}
if should_exit_clone.load(Ordering::Relaxed) {
break;
}
});
loop { loop {
// Check for exit FIRST
if should_exit.load(Ordering::Relaxed) {
return Ok(true); // User requested exit
}
let frame_start = std::time::Instant::now(); let frame_start = std::time::Instant::now();
// Calculate progress with easing // Calculate progress with easing
let linear_progress = timeline.progress(); let linear_progress = timeline.progress();
let eased_progress = self.easing.ease(linear_progress); let eased_progress = self.easing.ease(linear_progress);
// Check again before rendering
if should_exit.load(Ordering::Relaxed) {
return Ok(true); // User requested exit
}
// Apply effect // Apply effect
let effect_result = self.effect.apply(self.ascii_art, eased_progress); let effect_result = self.effect.apply(self.ascii_art, eased_progress);
@@ -92,11 +51,6 @@ impl<'a> Renderer<'a> {
effect_result.text.clone() effect_result.text.clone()
}; };
// Check before terminal operations
if should_exit.load(Ordering::Relaxed) {
return Ok(true); // User requested exit
}
// Render to terminal // Render to terminal
terminal.clear()?; terminal.clear()?;
terminal.refresh_size()?; terminal.refresh_size()?;
@@ -128,14 +82,9 @@ impl<'a> Renderer<'a> {
} }
} }
// Check if user wants to exit
if should_exit.load(Ordering::Relaxed) {
return Ok(true); // User requested exit
}
// Check if animation is complete before advancing // Check if animation is complete before advancing
if timeline.is_complete() { if timeline.is_complete() {
return Ok(false); // Animation completed naturally break;
} }
// Advance to next frame and wait // Advance to next frame and wait
@@ -144,21 +93,11 @@ impl<'a> Renderer<'a> {
let elapsed = frame_start.elapsed(); let elapsed = frame_start.elapsed();
if elapsed < frame_duration { if elapsed < frame_duration {
let sleep_duration = frame_duration - elapsed; sleep(frame_duration - elapsed).await;
// Break sleep into small chunks to check should_exit frequently
let chunk_duration = Duration::from_millis(5);
let mut remaining = sleep_duration;
while remaining > Duration::ZERO {
if should_exit.load(Ordering::Relaxed) {
return Ok(true); // User requested exit during sleep
}
let sleep_time = remaining.min(chunk_duration);
sleep(sleep_time).await;
remaining = remaining.saturating_sub(sleep_time);
}
} }
} }
Ok(())
} }
fn apply_colors(&self, text: &str, progress: f64) -> String { fn apply_colors(&self, text: &str, progress: f64) -> String {

View File

@@ -61,14 +61,8 @@ async fn run_piglet(args: PigletCli) -> Result<()> {
// Run animation // Run animation
loop { loop {
let user_exited = animation_engine.run(&mut terminal).await?; animation_engine.run(&mut terminal).await?;
// If user pressed exit key, stop looping
if user_exited {
break;
}
// If not looping, stop after one animation
if !args.loop_animation { if !args.loop_animation {
break; break;
} }