Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
140d5881af | ||
|
|
3d4fd8d048 | ||
|
|
cdc04ab266 | ||
|
|
46aff0e6b1 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -147,7 +147,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chkr"
|
name = "chkr"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argh",
|
"argh",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "chkr"
|
name = "chkr"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -6,11 +6,22 @@ VERSION="$(git cliff --bumped-version)"
|
|||||||
VERSION_CLEAN="${VERSION#v}"
|
VERSION_CLEAN="${VERSION#v}"
|
||||||
sed -i "s/^version = \".*\"/version = \"${VERSION_CLEAN}\"/" Cargo.toml
|
sed -i "s/^version = \".*\"/version = \"${VERSION_CLEAN}\"/" Cargo.toml
|
||||||
cargo check
|
cargo check
|
||||||
|
|
||||||
echo Press Y to commit version bump to ${VERSION_CLEAN}
|
echo Press Y to commit version bump to ${VERSION_CLEAN}
|
||||||
read -r CONFIRM
|
read -r CONFIRM
|
||||||
if [ "${CONFIRM}" != "Y" ]; then
|
if [ "${CONFIRM}" != "Y" ]; then
|
||||||
echo Aborting
|
echo Aborting
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git commit -am "chore: bump version to ${VERSION}"
|
git commit -am "chore: bump version to ${VERSION}"
|
||||||
git tag -am "Version ${VERSION}" "${VERSION}"
|
git tag -am "Version ${VERSION}" "${VERSION}"
|
||||||
|
|
||||||
|
echo Press Y to push commit and tag
|
||||||
|
read -r CONFIRM
|
||||||
|
if [ "${CONFIRM}" != "Y" ]; then
|
||||||
|
echo Aborting
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git push
|
||||||
|
git push --tags
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//! Abstraction around event sourcing for the checklist application.
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crossterm::event::{self, Event};
|
use crossterm::event::{self, Event};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|||||||
26
src/main.rs
26
src/main.rs
@@ -1,10 +1,10 @@
|
|||||||
/// A simple terminal checklist application.
|
//! A simple terminal checklist application.
|
||||||
mod event_source;
|
mod event_source;
|
||||||
mod terminal_guard;
|
mod terminal_guard;
|
||||||
/// UI components (todo list)
|
|
||||||
mod todo_list;
|
mod todo_list;
|
||||||
|
|
||||||
use anyhow::{Context as _, Result, anyhow, bail};
|
use anyhow::{Context as _, Result, anyhow, bail};
|
||||||
|
use argh::FromArgs;
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use crossterm::event::{self, EnableMouseCapture, Event, KeyCode};
|
use crossterm::event::{self, EnableMouseCapture, Event, KeyCode};
|
||||||
use crossterm::execute;
|
use crossterm::execute;
|
||||||
@@ -16,11 +16,14 @@ use ratatui::backend::CrosstermBackend;
|
|||||||
use std::io::{self, Read as _};
|
use std::io::{self, Read as _};
|
||||||
use terminal_guard::TerminalModeGuard;
|
use terminal_guard::TerminalModeGuard;
|
||||||
use todo_list::TodoList;
|
use todo_list::TodoList;
|
||||||
use argh::FromArgs;
|
|
||||||
|
|
||||||
#[derive(FromArgs)]
|
#[derive(FromArgs)]
|
||||||
/// chkr - terminal checklist
|
/// chkr - terminal checklist
|
||||||
struct Args {
|
struct Args {
|
||||||
|
/// load checklist from file instead of stdin
|
||||||
|
#[argh(option, short = 'f', long = "file")]
|
||||||
|
file: Option<String>,
|
||||||
|
|
||||||
/// print version and exit
|
/// print version and exit
|
||||||
#[argh(switch, short = 'V', long = "version")]
|
#[argh(switch, short = 'V', long = "version")]
|
||||||
version: bool,
|
version: bool,
|
||||||
@@ -34,13 +37,20 @@ fn main() -> Result<()> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut input = String::new();
|
let input: String = if let Some(path) = args.file {
|
||||||
io::stdin()
|
std::fs::read_to_string(&path).with_context(|| format!("reading file {path}"))?
|
||||||
.read_to_string(&mut input)
|
} else {
|
||||||
.context("reading stdin")?;
|
let mut input = String::new();
|
||||||
|
io::stdin()
|
||||||
|
.read_to_string(&mut input)
|
||||||
|
.context("reading stdin")?;
|
||||||
|
input
|
||||||
|
};
|
||||||
|
|
||||||
if input.trim().is_empty() {
|
if input.trim().is_empty() {
|
||||||
eprintln!("Provide text via stdin (pipe or heredoc). Example: \n cat file.txt | chkr");
|
eprintln!(
|
||||||
|
"Provide text via stdin (pipe or heredoc), or use --file. Example: \n cat file.txt | chkr"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//! Todo list UI component for the checklist application.
|
||||||
use ratatui::style::Style;
|
use ratatui::style::Style;
|
||||||
use ratatui::widgets::{Block, Borders, List, ListItem, ListState};
|
use ratatui::widgets::{Block, Borders, List, ListItem, ListState};
|
||||||
// use Frame via the crate root type `ratatui::Frame` in the signature below
|
// use Frame via the crate root type `ratatui::Frame` in the signature below
|
||||||
|
|||||||
Reference in New Issue
Block a user