Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration #63

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use camino::Utf8PathBuf;
use clap::Args;
use clap::Parser;
use clap::Subcommand;
use reqwest::Method;
Expand All @@ -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.
///
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::cli::Args;
use crate::git::Git;

pub struct Config {
git: Git,
args: Args,
}
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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")?;
Expand Down
Loading