1use anyhow::Result;
2use clap::{Parser, ValueHint};
3
4use crate::cmds::exec;
5use crate::model;
6
7#[derive(Parser, Clone, Debug)]
9#[command(author, about, long_about)]
10pub struct GitOptions {
11 #[arg(long, short, default_value = "*")]
13 trees: String,
14 #[arg(long, short = 'N', short_alias = 'n')]
16 dry_run: bool,
17 #[arg(long = "jobs", short = 'j', value_name = "JOBS")]
19 num_jobs: Option<usize>,
20 #[arg(short, long)]
22 quiet: bool,
23 #[arg(short, long, action = clap::ArgAction::Count)]
25 verbose: u8,
26 #[arg(default_value = "@*", value_hint=ValueHint::Other)]
28 query: String,
29 #[arg(
31 default_value = "status",
32 allow_hyphen_values = true,
33 trailing_var_arg = true
34 )]
35 command: Vec<String>,
36}
37
38impl From<GitOptions> for exec::ExecOptions {
40 fn from(git_options: GitOptions) -> Self {
41 exec::ExecOptions {
42 dry_run: git_options.dry_run,
43 num_jobs: git_options.num_jobs,
44 quiet: git_options.quiet,
45 verbose: git_options.verbose,
46 query: git_options.query,
47 command: {
48 let mut cmd = vec!["git".to_string()];
49 cmd.extend(git_options.command);
50 cmd
51 },
52 trees: git_options.trees,
53 }
54 }
55}
56
57pub fn main(app_context: &model::ApplicationContext, git_options: &mut GitOptions) -> Result<()> {
59 let mut exec_options: exec::ExecOptions = git_options.clone().into();
60
61 exec::main(app_context, &mut exec_options)
62}