Skip to content

Commit 1d84f61

Browse files
committed
fix clippy
1 parent c48d0a3 commit 1d84f61

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

src/args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::{
1313
path::PathBuf,
1414
};
1515

16+
#[derive(Clone)]
1617
pub struct CliArgs {
1718
pub theme: PathBuf,
1819
pub repo_path: RepoPath,

src/main.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ mod ui;
4747
mod version;
4848
mod watcher;
4949

50-
use crate::{app::App, args::process_cmdline};
50+
use crate::{
51+
app::App,
52+
args::{process_cmdline, CliArgs},
53+
};
5154
use anyhow::{bail, Result};
5255
use app::QuitState;
5356
use asyncgit::{
54-
ssh_key::private::PrivateKey,
5557
sync::{utils::repo_work_dir, RepoPath},
5658
AsyncGitNotification,
5759
};
@@ -131,12 +133,6 @@ fn main() -> Result<()> {
131133
if !valid_path(&cliargs.repo_path) {
132134
bail!("invalid path\nplease run gitui inside of a non-bare git repository");
133135
}
134-
135-
let key_config = KeyConfig::init()
136-
.map_err(|e| eprintln!("KeyConfig loading error: {e}"))
137-
.unwrap_or_default();
138-
let theme = Theme::init(&cliargs.theme);
139-
140136
setup_terminal()?;
141137
defer! {
142138
shutdown_terminal();
@@ -145,25 +141,16 @@ fn main() -> Result<()> {
145141
set_panic_handlers()?;
146142

147143
let mut terminal = start_terminal(io::stdout())?;
148-
let mut repo_path = cliargs.repo_path;
144+
let mut repo_path = cliargs.repo_path.clone();
149145
let input = Input::new();
150146

151-
let updater = if cliargs.notify_watcher {
152-
Updater::NotifyWatcher
153-
} else {
154-
Updater::Ticker
155-
};
156-
157147
loop {
158148
let quit_state = run_app(
159149
app_start,
160-
repo_path.clone(),
161-
theme.clone(),
162-
key_config.clone(),
150+
repo_path,
163151
&input,
164-
updater,
165152
&mut terminal,
166-
cliargs.ssh_secret_key.clone(),
153+
cliargs.clone(),
167154
)?;
168155

169156
match quit_state {
@@ -180,13 +167,20 @@ fn main() -> Result<()> {
180167
fn run_app(
181168
app_start: Instant,
182169
repo: RepoPath,
183-
theme: Theme,
184-
key_config: KeyConfig,
185170
input: &Input,
186-
updater: Updater,
187171
terminal: &mut Terminal<CrosstermBackend<io::Stdout>>,
188-
ssh_secret_key: Option<PrivateKey>,
172+
cliargs: CliArgs,
189173
) -> Result<QuitState, anyhow::Error> {
174+
let key_config = KeyConfig::init()
175+
.map_err(|e| eprintln!("KeyConfig loading error: {e}"))
176+
.unwrap_or_default();
177+
let theme = Theme::init(&cliargs.theme);
178+
let updater = if cliargs.notify_watcher {
179+
Updater::NotifyWatcher
180+
} else {
181+
Updater::Ticker
182+
};
183+
190184
let (tx_git, rx_git) = unbounded();
191185
let (tx_app, rx_app) = unbounded();
192186

@@ -211,7 +205,7 @@ fn run_app(
211205
input.clone(),
212206
theme,
213207
key_config,
214-
ssh_secret_key,
208+
cliargs.ssh_secret_key,
215209
)?;
216210

217211
let mut spinner = Spinner::default();

0 commit comments

Comments
 (0)