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
use clap::ValueHint;
#[derive(clap::Args, Default, Debug)]
#[clap(next_help_heading = "Git Options")]
pub struct GitOptions {
#[clap(short = 'C', num_args = 1, value_hint=ValueHint::DirPath)]
pub change_dir: Option<String>,
#[clap(long, value_hint=ValueHint::DirPath)]
pub git_dir: Option<String>,
#[clap(long, value_hint=ValueHint::DirPath)]
pub work_tree: Option<String>,
}
#[cfg(feature = "git-wrapper")]
impl TryFrom<&GitOptions> for git_wrapper::Repository {
type Error = git_wrapper::RepoError;
#[inline]
fn try_from(args: &GitOptions) -> Result<Self, Self::Error> {
Self::from_args(
args.change_dir.as_deref(),
args.git_dir.as_deref(),
args.work_tree.as_deref(),
)
}
}