Skip to main content

ralph/cli/
app.rs

1//! `ralph app ...` command group for macOS GUI integration.
2//!
3//! Responsibilities:
4//! - Define clap structures for app-related commands (currently `open`).
5//! - Route app subcommands to the command implementation layer (`crate::commands::app`).
6//!
7//! Not handled here:
8//! - Building or installing the SwiftUI app bundle (see `apps/RalphMac/`).
9//! - Any queue/runner logic (Ralph remains CLI-first; the GUI shells out to the CLI).
10//!
11//! Invariants/assumptions:
12//! - `ralph app open` is macOS-only; non-macOS platforms return a clear error.
13
14use anyhow::Result;
15use clap::{Args, Subcommand};
16use std::path::PathBuf;
17
18use crate::commands::app as app_cmd;
19
20pub fn handle_app(cmd: AppCommand) -> Result<()> {
21    match cmd {
22        AppCommand::Open(args) => app_cmd::open(args),
23    }
24}
25
26#[derive(Args)]
27pub struct AppArgs {
28    #[command(subcommand)]
29    pub command: AppCommand,
30}
31
32#[derive(Subcommand)]
33pub enum AppCommand {
34    /// Open the macOS Ralph app.
35    #[command(
36        about = "Open the macOS Ralph app",
37        after_long_help = "Examples:\n  ralph app open\n  ralph app open --bundle-id com.mitchfultz.ralph\n  ralph app open --path /Applications/Ralph.app\n"
38    )]
39    Open(AppOpenArgs),
40}
41
42#[derive(Args, Debug, Clone)]
43pub struct AppOpenArgs {
44    /// Bundle identifier to open (default: com.mitchfultz.ralph).
45    ///
46    /// Uses: `open -b <bundle_id>`.
47    #[arg(long, value_name = "BUNDLE_ID", conflicts_with = "path")]
48    pub bundle_id: Option<String>,
49
50    /// Open the app at a specific `.app` bundle path (useful for dev builds).
51    ///
52    /// Uses: `open <path>`.
53    #[arg(long, value_name = "PATH", conflicts_with = "bundle_id")]
54    pub path: Option<PathBuf>,
55
56    /// Workspace directory to open (defaults to current working directory).
57    /// Used internally when launching from CLI to pass context to the macOS app.
58    #[arg(long, value_name = "DIR", hide = true)]
59    pub workspace: Option<PathBuf>,
60}