bonds_cli/args.rs
1use clap::{Parser, Subcommand};
2use std::path::PathBuf;
3
4#[derive(Parser)]
5#[command(
6 name = "bond",
7 version,
8 about = "Manage directory bonds (symlinks with tracking)"
9)]
10pub struct Cli {
11 /// Path to the database file (overrides default ~/.bonds/bonds.db)
12 #[arg(long, global = true)]
13 pub db: Option<PathBuf>,
14
15 #[command(subcommand)]
16 pub command: Commands,
17}
18
19#[derive(Subcommand)]
20pub enum Commands {
21 /// Create a new bond from source to target
22 Add {
23 /// The source directory or file to bond
24 source: PathBuf,
25 /// The target location (defaults to current directory + source name)
26 target: Option<PathBuf>,
27 /// Bond each child of source as a separate bond into target
28 #[arg(long)]
29 contents: bool,
30 /// Give this bond a name for easy reference
31 #[arg(long)]
32 name: Option<String>,
33 },
34
35 /// List all bonds
36 List,
37
38 /// Show details of a specific bond
39 Info {
40 /// Bond ID
41 id: String,
42 },
43
44 /// Remove a bond
45 Remove {
46 /// Bond ID
47 id: String,
48 /// Also delete the target directory/file (not just the symlink)
49 #[arg(long)]
50 with_target: bool,
51 },
52
53 /// View or modify configuration
54 Config {
55 #[command(subcommand)]
56 action: ConfigAction,
57 },
58
59 /// Update an existing bond's source or target
60 Update {
61 /// Bond ID (or prefix)
62 id: String,
63 /// New source path
64 #[arg(long)]
65 source: Option<PathBuf>,
66 /// New target path
67 #[arg(long)]
68 target: Option<PathBuf>,
69 /// Set or change the bond's name
70 #[arg(long)]
71 name: Option<String>,
72 },
73
74 /// Move a bond's target to a new directory
75 Migrate {
76 /// Bond name or ID prefix
77 id: String,
78 /// Destination directory (defaults to configured default directory)
79 dest: Option<PathBuf>,
80 },
81}
82
83#[derive(Subcommand)]
84pub enum ConfigAction {
85 /// Get the current value of a config key
86 Get {
87 /// Config key to read (e.g., "default")
88 key: String,
89 },
90 /// Set a config key to a new value
91 Set {
92 /// Config key to set (e.g., "default")
93 key: String,
94 /// New value
95 value: String,
96 },
97}