Skip to main content

open_loops/
cli_command.rs

1// Clap command surface shared by runtime and `build.rs` (via `include!`).
2use clap::{Parser, Subcommand};
3use std::path::PathBuf;
4
5#[derive(Parser)]
6#[command(name = "loops", version, about = "Recover the context of paused work")]
7#[command(args_conflicts_with_subcommands = true)]
8pub struct Cli {
9    #[command(subcommand)]
10    pub command: Option<Command>,
11    /// Filter the inventory (e.g. `loops api idle:>7d`). See ADR 0003 grammar.
12    #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
13    pub query: Vec<String>,
14    /// Ignore cached inventory memo and recompute ahead/behind from git
15    #[arg(long)]
16    pub fresh: bool,
17}
18
19#[derive(Subcommand)]
20pub enum Command {
21    /// Register repository roots (e.g. loops init ~/repo)
22    Init { paths: Vec<PathBuf> },
23    /// Distill a loop's context: why, done, remaining, next step
24    Resume {
25        // A single String, not a trailing_var_arg Vec like list/refresh: Resume
26        // takes option flags (--dry-run/--fresh) after the positional, and a
27        // trailing var-arg would swallow those flags into the query.
28        query: String,
29        /// Show matched git commits and AI sessions without calling the LLM
30        #[arg(long)]
31        dry_run: bool,
32        /// Ignore cached inventory memo and recompute ahead/behind from git
33        #[arg(long)]
34        fresh: bool,
35    },
36    /// Drop a dead loop from the list (repo/branch format)
37    Ignore { key: String },
38    /// List git worktrees with a cleanup verdict (alias: wt)
39    #[command(visible_alias = "wt")]
40    Worktrees,
41    /// Generate a shell completion script (bash, zsh, fish, ...)
42    Completions { shell: clap_complete::Shell },
43    /// Reindex the ahead/behind inventory for all repos (or those matching a query)
44    Refresh {
45        /// Optional query to scope the refresh (same syntax as `loops [query]`)
46        query: Vec<String>,
47    },
48}