Skip to main content

angular_switcher/
cli.rs

1use clap::{ArgAction, Parser};
2use std::path::PathBuf;
3
4#[derive(Debug, Parser)]
5#[command(
6    name = "angular-switcher",
7    about = "Switch between Angular component files (.ts, .html, styles, .spec.ts) from the Zed editor.",
8    long_about = "Resolves the sibling file of an Angular component (the .ts, template, style \
9                  or spec) and opens it in Zed via the `zed` CLI. Designed to be invoked from \
10                  a Zed task bound to a keyboard shortcut. See the README for the recommended \
11                  tasks.json and keymap.json snippets.",
12    version
13)]
14#[allow(clippy::struct_excessive_bools)]
15pub struct Cli {
16    /// Path to the current file. Defaults to `$ZED_FILE`.
17    pub file: Option<PathBuf>,
18
19    /// Switch directly to a specific target: ts, html, style, spec.
20    #[arg(short = 't', long, value_name = "TARGET")]
21    pub to: Option<String>,
22
23    /// Cycle to the next sibling. Default behavior when --to is omitted.
24    #[arg(short = 'c', long, action = ArgAction::SetTrue)]
25    pub cycle: bool,
26
27    /// Cycle backwards instead of forwards.
28    #[arg(short = 'r', long, action = ArgAction::SetTrue)]
29    pub reverse: bool,
30
31    /// Print the resolved sibling path to stdout instead of launching Zed.
32    #[arg(long, action = ArgAction::SetTrue)]
33    pub print: bool,
34
35    /// Skip the `zed` invocation but still exit 0 on success (for scripting).
36    #[arg(long, action = ArgAction::SetTrue)]
37    pub no_launch: bool,
38
39    /// Override the config file location.
40    #[arg(long, value_name = "PATH")]
41    pub config: Option<PathBuf>,
42
43    /// Log resolution steps to stderr.
44    #[arg(short = 'v', long, action = ArgAction::SetTrue)]
45    pub verbose: bool,
46}