Skip to main content

review_queue/
cli.rs

1use std::path::PathBuf;
2
3use clap::{Parser, Subcommand};
4
5#[derive(Parser, Debug)]
6#[command(name = "rq", version, about = "Track and check out your code reviews")]
7pub struct Cli {
8    /// Path to config.toml (default: XDG config dir)
9    #[arg(long, global = true)]
10    pub config: Option<PathBuf>,
11
12    #[command(subcommand)]
13    pub command: Option<Command>,
14}
15
16#[derive(Subcommand, Debug)]
17pub enum Command {
18    /// Fetch review queues and update existing workspaces, removing one once its review resolves
19    /// and is clean. Never creates a new workspace - use `rq fetch` (or the open-locally hotkey
20    /// in `rq show`) for that.
21    Sync {
22        /// Only sync the named source ("gh" or "phab").
23        #[arg(long)]
24        source: Option<String>,
25        #[arg(long)]
26        dry_run: bool,
27    },
28    /// Show tracked reviews. Opens an interactive TUI when stdout is a terminal (arrow keys or
29    /// j/k to move, enter to open the review locally in a subshell, `o` to open it in your
30    /// browser, `d` to delete its local workspace, `q` to quit); prints a plain table otherwise,
31    /// or with `--plain`. This is the default when no subcommand is given.
32    Show {
33        #[arg(long)]
34        json: bool,
35        /// Also show reviews that are out of your queue but not yet resolved.
36        #[arg(long)]
37        all: bool,
38        /// Print a plain table instead of the interactive TUI, even on a terminal.
39        #[arg(long)]
40        plain: bool,
41    },
42    /// Print a review's workspace path, e.g. `cd $(rq path D12345)`.
43    Path {
44        /// A review id, or unique prefix of one (e.g. "D123" or "moz/D123").
45        id: String,
46    },
47    /// Fetch a review locally: resolve its canonical repo (asking before cloning one, unless
48    /// `auto_clone` is set) and create a worktree/workspace for it. `rq sync` never does this on
49    /// its own; use this (or the open-locally hotkey in `rq show`) for reviews that actually
50    /// warrant checking out.
51    Fetch {
52        /// A review id, or unique prefix of one (e.g. "D123" or "moz/D123").
53        id: String,
54    },
55    /// Manage canonical repos (discovered by scanning `workdir`, or tool-managed clones).
56    Repo {
57        #[command(subcommand)]
58        command: RepoCommand,
59    },
60    /// Print a shell function (`rqcd`) for sourcing in your shell rc.
61    ShellInit { shell: Shell },
62}
63
64#[derive(Subcommand, Debug)]
65pub enum RepoCommand {
66    /// List canonical repos and how many live workspaces each has.
67    List,
68    /// Delete a tool-managed clone (refuses for a discovered repo, or if it still has
69    /// workspaces).
70    Rm { url: String },
71}
72
73#[derive(Debug, Clone, clap::ValueEnum)]
74pub enum Shell {
75    Bash,
76    Zsh,
77    Fish,
78}