@@ -54,9 +54,13 @@ async fn main() -> Result<()> {
54
54
handler,
55
55
} ) => {
56
56
let handler = * handler;
57
- command:: handle_changes ( & args. current_dir , args. json , handler, description)
57
+ let project = get_or_init_project ( & args. current_dir ) ?;
58
+ command:: handle_changes ( & project, args. json , handler, description)
59
+ }
60
+ None => {
61
+ let project = get_or_init_project ( & args. current_dir ) ?;
62
+ command:: list_actions ( & project, args. json , 0 , 10 )
58
63
}
59
- None => command:: list_actions ( & args. current_dir , args. json , 0 , 10 ) ,
60
64
} ,
61
65
Subcommands :: Metrics {
62
66
command_name,
@@ -112,7 +116,8 @@ async fn main() -> Result<()> {
112
116
}
113
117
} ,
114
118
Subcommands :: Base ( base:: Platform { cmd } ) => {
115
- let result = base:: handle ( cmd, & args. current_dir , args. json ) ;
119
+ let project = get_or_init_project ( & args. current_dir ) ?;
120
+ let result = base:: handle ( cmd, & project, args. json ) ;
116
121
metrics_if_configured (
117
122
app_settings,
118
123
match cmd {
@@ -125,39 +130,45 @@ async fn main() -> Result<()> {
125
130
Ok ( ( ) )
126
131
}
127
132
Subcommands :: Branch ( branch:: Platform { cmd } ) => {
128
- let result = branch:: handle ( cmd, & args. current_dir , args. json ) ;
133
+ let project = get_or_init_project ( & args. current_dir ) ?;
134
+ let result = branch:: handle ( cmd, & project, args. json ) ;
129
135
metrics_if_configured ( app_settings, CommandName :: BranchNew , props ( start, & result) ) . ok ( ) ;
130
136
Ok ( ( ) )
131
137
}
132
138
Subcommands :: Log => {
133
- let result = log:: commit_graph ( & args. current_dir , args. json ) ;
139
+ let project = get_or_init_project ( & args. current_dir ) ?;
140
+ let result = log:: commit_graph ( & project, args. json ) ;
134
141
metrics_if_configured ( app_settings, CommandName :: Log , props ( start, & result) ) . ok ( ) ;
135
142
Ok ( ( ) )
136
143
}
137
144
Subcommands :: Status {
138
145
show_files,
139
146
verbose,
140
147
} => {
141
- let result = status:: worktree ( & args. current_dir , args. json , * show_files, * verbose) ;
148
+ let project = get_or_init_project ( & args. current_dir ) ?;
149
+ let result = status:: worktree ( & project, args. json , * show_files, * verbose) ;
142
150
metrics_if_configured ( app_settings, CommandName :: Status , props ( start, & result) ) . ok ( ) ;
143
151
Ok ( ( ) )
144
152
}
145
153
Subcommands :: Stf { verbose } => {
146
- let result = status:: worktree ( & args. current_dir , args. json , true , * verbose) ;
154
+ let project = get_or_init_project ( & args. current_dir ) ?;
155
+ let result = status:: worktree ( & project, args. json , true , * verbose) ;
147
156
metrics_if_configured ( app_settings, CommandName :: Stf , props ( start, & result) ) . ok ( ) ;
148
157
Ok ( ( ) )
149
158
}
150
159
Subcommands :: Rub { source, target } => {
151
- let result = rub:: handle ( & args. current_dir , args. json , source, target)
152
- . context ( "Rubbed the wrong way." ) ;
160
+ let project = get_or_init_project ( & args. current_dir ) ?;
161
+ let result =
162
+ rub:: handle ( & project, args. json , source, target) . context ( "Rubbed the wrong way." ) ;
153
163
if let Err ( e) = & result {
154
164
eprintln ! ( "{} {}" , e, e. root_cause( ) ) ;
155
165
}
156
166
metrics_if_configured ( app_settings, CommandName :: Rub , props ( start, & result) ) . ok ( ) ;
157
167
Ok ( ( ) )
158
168
}
159
169
Subcommands :: Mark { target, delete } => {
160
- let result = mark:: handle ( & args. current_dir , args. json , target, * delete)
170
+ let project = get_or_init_project ( & args. current_dir ) ?;
171
+ let result = mark:: handle ( & project, args. json , target, * delete)
161
172
. context ( "Can't mark this. Taaaa-na-na-na. Can't mark this." ) ;
162
173
if let Err ( e) = & result {
163
174
eprintln ! ( "{} {}" , e, e. root_cause( ) ) ;
@@ -166,7 +177,8 @@ async fn main() -> Result<()> {
166
177
Ok ( ( ) )
167
178
}
168
179
Subcommands :: Unmark => {
169
- let result = mark:: unmark ( & args. current_dir , args. json )
180
+ let project = get_or_init_project ( & args. current_dir ) ?;
181
+ let result = mark:: unmark ( & project, args. json )
170
182
. context ( "Can't unmark this. Taaaa-na-na-na. Can't unmark this." ) ;
171
183
if let Err ( e) = & result {
172
184
eprintln ! ( "{} {}" , e, e. root_cause( ) ) ;
@@ -179,8 +191,9 @@ async fn main() -> Result<()> {
179
191
branch,
180
192
only,
181
193
} => {
194
+ let project = get_or_init_project ( & args. current_dir ) ?;
182
195
let result = commit:: commit (
183
- & args . current_dir ,
196
+ & project ,
184
197
args. json ,
185
198
message. as_deref ( ) ,
186
199
branch. as_deref ( ) ,
@@ -190,27 +203,32 @@ async fn main() -> Result<()> {
190
203
result
191
204
}
192
205
Subcommands :: New { target } => {
193
- let result = commit:: insert_blank_commit ( & args. current_dir , args. json , target) ;
206
+ let project = get_or_init_project ( & args. current_dir ) ?;
207
+ let result = commit:: insert_blank_commit ( & project, args. json , target) ;
194
208
metrics_if_configured ( app_settings, CommandName :: New , props ( start, & result) ) . ok ( ) ;
195
209
result
196
210
}
197
211
Subcommands :: Describe { commit } => {
198
- let result = describe:: edit_commit_message ( & args. current_dir , args. json , commit) ;
212
+ let project = get_or_init_project ( & args. current_dir ) ?;
213
+ let result = describe:: edit_commit_message ( & project, args. json , commit) ;
199
214
metrics_if_configured ( app_settings, CommandName :: Describe , props ( start, & result) ) . ok ( ) ;
200
215
result
201
216
}
202
217
Subcommands :: Oplog { since } => {
203
- let result = oplog:: show_oplog ( & args. current_dir , args. json , since. as_deref ( ) ) ;
218
+ let project = get_or_init_project ( & args. current_dir ) ?;
219
+ let result = oplog:: show_oplog ( & project, args. json , since. as_deref ( ) ) ;
204
220
metrics_if_configured ( app_settings, CommandName :: Oplog , props ( start, & result) ) . ok ( ) ;
205
221
result
206
222
}
207
223
Subcommands :: Restore { oplog_sha } => {
208
- let result = oplog:: restore_to_oplog ( & args. current_dir , args. json , oplog_sha) ;
224
+ let project = get_or_init_project ( & args. current_dir ) ?;
225
+ let result = oplog:: restore_to_oplog ( & project, args. json , oplog_sha) ;
209
226
metrics_if_configured ( app_settings, CommandName :: Restore , props ( start, & result) ) . ok ( ) ;
210
227
result
211
228
}
212
229
Subcommands :: Undo => {
213
- let result = oplog:: undo_last_operation ( & args. current_dir , args. json ) ;
230
+ let project = get_or_init_project ( & args. current_dir ) ?;
231
+ let result = oplog:: undo_last_operation ( & project, args. json ) ;
214
232
metrics_if_configured ( app_settings, CommandName :: Undo , props ( start, & result) ) . ok ( ) ;
215
233
result
216
234
}
0 commit comments