1use clap::ValueHint;
4
5#[derive(clap::Args, Default, Debug)]
7#[clap(next_help_heading = "Git Options")]
8pub struct GitOptions {
9 #[clap(short = 'C', num_args = 1, value_hint=ValueHint::DirPath)]
11 pub change_dir: Option<String>,
12 #[clap(long, value_hint=ValueHint::DirPath)]
14 pub git_dir: Option<String>,
15 #[clap(long, value_hint=ValueHint::DirPath)]
17 pub work_tree: Option<String>,
18}
19
20#[cfg(feature = "git-wrapper")]
21impl TryFrom<&GitOptions> for git_wrapper::Repository {
22 type Error = git_wrapper::RepoError;
23 #[inline]
24 fn try_from(args: &GitOptions) -> Result<Self, Self::Error> {
25 Self::from_args(
26 args.change_dir.as_deref(),
27 args.git_dir.as_deref(),
28 args.work_tree.as_deref(),
29 )
30 }
31}