diff --git a/src/cli.rs b/src/cli.rs index 5fa9372..22ed56d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,5 +1,4 @@ use camino::Utf8PathBuf; -use clap::Args; use clap::Parser; use clap::Subcommand; use reqwest::Method; @@ -13,7 +12,7 @@ use crate::patchset::Patchset; #[derive(Debug, Clone, Parser)] #[command(version, author, about)] #[command(max_term_width = 100, disable_help_subcommand = true)] -pub struct Opts { +pub struct Args { /// Log filter directives, of the form `target[span{field=value}]=level`, where all components /// except the level are optional. /// @@ -152,7 +151,7 @@ pub enum Restack { }, } -#[derive(Debug, Clone, Args)] +#[derive(Debug, Clone, clap::Args)] pub struct RestackContinue { /// If you ran `git rebase --continue` on your own and then checked something else out, /// `git-gr` will not be able to determine the new commit hash for the in-progress restack diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..1329b34 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,7 @@ +use crate::cli::Args; +use crate::git::Git; + +pub struct Config { + git: Git, + args: Args, +} diff --git a/src/main.rs b/src/main.rs index bd21347..5a69735 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ mod change_status; mod cli; mod commit_hash; mod commit_info; +mod config; mod current_exe; mod current_patch_set; mod dependency_graph; @@ -40,7 +41,7 @@ mod unicode_tree; use calm_io::stdoutln; use clap::CommandFactory; use clap::Parser; -use cli::Opts; +use cli::Args; use command_error::CommandExt; use format_bulleted_list::format_bulleted_list; use git::Git; @@ -53,7 +54,7 @@ use restack::create_todo; use miette::Context; fn main() -> miette::Result<()> { - let opts = Opts::parse(); + let opts = Args::parse(); install_tracing(&opts.log)?; match opts.command { @@ -143,12 +144,12 @@ fn main() -> miette::Result<()> { } } cli::Command::Completions { shell } => { - let mut clap_command = cli::Opts::command(); + let mut clap_command = cli::Args::command(); clap_complete::generate(shell, &mut clap_command, "git-gr", &mut std::io::stdout()); } #[cfg(feature = "clap_mangen")] cli::Command::Manpages { out_dir } => { - let clap_command = cli::Opts::command(); + let clap_command = cli::Args::command(); clap_mangen::generate_to(clap_command, out_dir) .into_diagnostic() .wrap_err("Failed to generate man pages")?;