Skip to content

Commit 5de679e

Browse files
zippoxerclaude
andcommitted
Add CLI argument support for initial search query
`recall foo bar` now opens with "foo bar" pre-filled in the search box and results displayed immediately. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f676516 commit 5de679e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "recall"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
description = "Search and resume Claude Code and Codex CLI conversations"
66

src/app.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub struct App {
6060
}
6161

6262
impl App {
63-
pub fn new() -> Result<Self> {
63+
pub fn new(initial_query: String) -> Result<Self> {
6464
let cache_dir = dirs::cache_dir()
6565
.unwrap_or_else(|| PathBuf::from("."))
6666
.join("recall");
@@ -82,8 +82,8 @@ impl App {
8282
background_index(index_path_clone, state_path, tx);
8383
});
8484

85-
Ok(Self {
86-
query: String::new(),
85+
let mut app = Self {
86+
query: initial_query,
8787
results: Vec::new(),
8888
selected: 0,
8989
list_scroll: 0,
@@ -100,7 +100,14 @@ impl App {
100100
indexing: true,
101101
search_scope: SearchScope::Folder(launch_cwd.clone()),
102102
launch_cwd,
103-
})
103+
};
104+
105+
// If there's an initial query, run the search immediately
106+
if !app.query.is_empty() {
107+
let _ = app.search();
108+
}
109+
110+
Ok(app)
104111
}
105112

106113
/// Check for indexing updates (call this in the main loop)

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ use crossterm::event::{self, Event, KeyCode, KeyModifiers, MouseEventKind};
1212
use std::time::Duration;
1313

1414
fn main() -> Result<()> {
15+
// Collect command-line args (skip program name, join with spaces)
16+
let initial_query: String = std::env::args().skip(1).collect::<Vec<_>>().join(" ");
17+
1518
// Initialize app (starts background indexing automatically)
16-
let mut app = App::new()?;
19+
let mut app = App::new(initial_query)?;
1720

1821
// Initialize terminal
1922
let mut terminal = tui::init()?;

0 commit comments

Comments
 (0)