heddle_cli_args/cli/cli_args/commands_shell.rs
1// SPDX-License-Identifier: Apache-2.0
2//! Shell integration helpers.
3
4use clap::Subcommand;
5
6#[derive(Clone, Copy, Debug, clap::ValueEnum, PartialEq, Eq)]
7pub enum ShellKind {
8 Zsh,
9 Bash,
10 Fish,
11}
12
13#[derive(Clone, Copy, Debug, clap::ValueEnum, PartialEq, Eq)]
14pub enum CompletionSubject {
15 Threads,
16 Markers,
17}
18
19#[derive(Subcommand, Clone)]
20pub enum ShellCommands {
21 /// Emit a shell wrapper function on stdout. Source it from your
22 /// shell rc to make `heddle start`, `heddle thread switch`, and
23 /// `heddle thread cd` auto-`cd` into the target thread's
24 /// worktree.
25 ///
26 /// Example install:
27 /// echo 'eval "$(heddle shell init zsh)"' >> ~/.zshrc
28 Init {
29 /// Shell to emit a function for.
30 #[arg(value_enum)]
31 kind: ShellKind,
32 },
33
34 /// Generate a shell completion script on stdout.
35 Completion {
36 /// Shell to generate completion for.
37 shell: String,
38 },
39
40 /// Print a compact prompt segment: current thread, dirty marker,
41 /// and remote divergence. Intended for PS1 helpers.
42 ///
43 /// Example:
44 /// PS1='$(__heddle_ps1) '" after sourcing `heddle shell init bash`
45 Prompt,
46}