generated from eblume/project-template
Run rustfmt over files landed in earlier commits this session that weren't fmt-checked (heph-quickadd, the heph-tui undo/move wave, the hephd quickadd supervisor). Pure formatting (struct/if-else expansion, line wrapping); no behavior change. Restores `cargo fmt --check` clean for CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
82 lines
2.6 KiB
Rust
82 lines
2.6 KiB
Rust
//! `heph-quickadd` — the global quick-capture popover (tech-spec §8).
|
|
//!
|
|
//! A tiny always-warm egui agent: ⌘' shows a single-line capture field that
|
|
//! parses Todoist-style inline syntax (`p2 #Chores tomorrow every 3 days`) and
|
|
//! creates a task over the `hephd` unix socket. It is **supervised by hephd**
|
|
//! (spawned in local mode on macOS), so the user installs/manages exactly one
|
|
//! service — there is no separate launch agent.
|
|
//!
|
|
//! See [`app`] for the snappiness design (warm window, optimistic save).
|
|
|
|
mod app;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use clap::{Parser, Subcommand};
|
|
// Re-export egui through eframe so we can name `egui::ViewportBuilder` here.
|
|
use eframe::egui;
|
|
|
|
use app::QuickAdd;
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(
|
|
name = "heph-quickadd",
|
|
about = "Global quick-capture popover for hephaestus"
|
|
)]
|
|
struct Cli {
|
|
/// hephd socket to talk to (defaults to $HEPH_SOCKET or the standard path).
|
|
#[arg(long, global = true)]
|
|
socket: Option<PathBuf>,
|
|
|
|
#[command(subcommand)]
|
|
cmd: Option<Cmd>,
|
|
}
|
|
|
|
#[derive(Subcommand, Debug)]
|
|
enum Cmd {
|
|
/// Run the warm agent (the default; this is what hephd spawns).
|
|
Run,
|
|
/// Show the popover immediately on launch — handy for iterating without ⌘'.
|
|
Once,
|
|
}
|
|
|
|
fn resolve_socket(flag: Option<PathBuf>) -> PathBuf {
|
|
flag.or_else(|| std::env::var_os("HEPH_SOCKET").map(PathBuf::from))
|
|
.unwrap_or_else(hephd::default_socket_path)
|
|
}
|
|
|
|
fn main() -> eframe::Result {
|
|
let cli = Cli::parse();
|
|
let socket = resolve_socket(cli.socket);
|
|
let start_visible = matches!(cli.cmd, Some(Cmd::Once));
|
|
|
|
let viewport = egui::ViewportBuilder::default()
|
|
.with_title("heph quick add")
|
|
.with_inner_size([620.0, 150.0])
|
|
.with_min_inner_size([620.0, 150.0])
|
|
.with_decorations(false)
|
|
.with_transparent(true)
|
|
.with_resizable(false)
|
|
.with_always_on_top()
|
|
// Start hidden + warm; ⌘' toggles it visible with zero re-init cost.
|
|
.with_visible(start_visible);
|
|
|
|
let native_options = eframe::NativeOptions {
|
|
viewport,
|
|
// macOS: run as an accessory app — no Dock icon, no menu bar.
|
|
event_loop_builder: Some(Box::new(|_builder| {
|
|
#[cfg(target_os = "macos")]
|
|
{
|
|
use winit::platform::macos::{ActivationPolicy, EventLoopBuilderExtMacOS};
|
|
_builder.with_activation_policy(ActivationPolicy::Accessory);
|
|
}
|
|
})),
|
|
..Default::default()
|
|
};
|
|
|
|
eframe::run_native(
|
|
"heph-quickadd",
|
|
native_options,
|
|
Box::new(move |cc| Ok(Box::new(QuickAdd::new(cc, socket, start_visible)))),
|
|
)
|
|
}
|