@@ -47,11 +47,13 @@ mod ui;
47
47
mod version;
48
48
mod watcher;
49
49
50
- use crate :: { app:: App , args:: process_cmdline} ;
50
+ use crate :: {
51
+ app:: App ,
52
+ args:: { process_cmdline, CliArgs } ,
53
+ } ;
51
54
use anyhow:: { bail, Result } ;
52
55
use app:: QuitState ;
53
56
use asyncgit:: {
54
- ssh_key:: private:: PrivateKey ,
55
57
sync:: { utils:: repo_work_dir, RepoPath } ,
56
58
AsyncGitNotification ,
57
59
} ;
@@ -131,12 +133,6 @@ fn main() -> Result<()> {
131
133
if !valid_path ( & cliargs. repo_path ) {
132
134
bail ! ( "invalid path\n please run gitui inside of a non-bare git repository" ) ;
133
135
}
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
-
140
136
setup_terminal ( ) ?;
141
137
defer ! {
142
138
shutdown_terminal( ) ;
@@ -145,25 +141,16 @@ fn main() -> Result<()> {
145
141
set_panic_handlers ( ) ?;
146
142
147
143
let mut terminal = start_terminal ( io:: stdout ( ) ) ?;
148
- let mut repo_path = cliargs. repo_path ;
144
+ let mut repo_path = cliargs. repo_path . clone ( ) ;
149
145
let input = Input :: new ( ) ;
150
146
151
- let updater = if cliargs. notify_watcher {
152
- Updater :: NotifyWatcher
153
- } else {
154
- Updater :: Ticker
155
- } ;
156
-
157
147
loop {
158
148
let quit_state = run_app (
159
149
app_start,
160
- repo_path. clone ( ) ,
161
- theme. clone ( ) ,
162
- key_config. clone ( ) ,
150
+ repo_path,
163
151
& input,
164
- updater,
165
152
& mut terminal,
166
- cliargs. ssh_secret_key . clone ( ) ,
153
+ cliargs. clone ( ) ,
167
154
) ?;
168
155
169
156
match quit_state {
@@ -180,13 +167,20 @@ fn main() -> Result<()> {
180
167
fn run_app (
181
168
app_start : Instant ,
182
169
repo : RepoPath ,
183
- theme : Theme ,
184
- key_config : KeyConfig ,
185
170
input : & Input ,
186
- updater : Updater ,
187
171
terminal : & mut Terminal < CrosstermBackend < io:: Stdout > > ,
188
- ssh_secret_key : Option < PrivateKey > ,
172
+ cliargs : CliArgs ,
189
173
) -> 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
+
190
184
let ( tx_git, rx_git) = unbounded ( ) ;
191
185
let ( tx_app, rx_app) = unbounded ( ) ;
192
186
@@ -211,7 +205,7 @@ fn run_app(
211
205
input. clone ( ) ,
212
206
theme,
213
207
key_config,
214
- ssh_secret_key,
208
+ cliargs . ssh_secret_key ,
215
209
) ?;
216
210
217
211
let mut spinner = Spinner :: default ( ) ;
0 commit comments