1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Subcommand)]
pub enum PoolCommands {
/// List existing pools.
List,
/// Show the contents of the current pool.
Show,
/// Create a new pool.
New {
label: String,
#[clap(parse(from_os_str))]
root: Option<PathBuf>,
},
/// Set the current pool.
Set { label: String },
/// Move the current pool root.
///
/// This command only updates the pool configuration file, it does
/// not however move the managed repositories.
Move {
#[clap(parse(from_os_str))]
root: PathBuf,
},
/// Change the current pool label.
Rename { label: String },
/// Add an exclusion rule for this pool discovery.
Exclude { pattern: String },
/// Clone missing repositories of the current pool, checkout appropriate branches.
Checkout,
/// Save managed repositories current state.
Discover,
}
#[derive(Debug, Subcommand)]
pub enum GitCommand {
#[clap(external_subcommand)]
Command(Vec<String>),
}
#[derive(Debug, Subcommand)]
pub enum ApplicationCommands {
/// Create or manage a pool.
///
/// When run without a subcommand, `gmux pool` will output
/// the current pool.
Pool {
#[clap(subcommand)]
pool_command: Option<PoolCommands>,
},
/// Run any git command on every repository of the current pool.
Command {
#[clap(short, long)]
exclude_filter: Option<String>,
#[clap(short, long)]
filter: Option<String>,
#[clap(subcommand)]
command: GitCommand,
},
}
#[derive(Debug, Parser)]
#[clap(author, version, about, name = "gmux")]
/// Manage multiple git repositories with ease.
pub struct Application {
#[clap(subcommand)]
pub command: ApplicationCommands,
}