@@ -193,48 +193,26 @@ impl ServiceCommand<'_> {
193
193
service_manager : & GeneralServiceManager ,
194
194
) -> Result < ExecCommand , SystemServiceError > {
195
195
let config_path = service_manager. config_path . clone ( ) ;
196
+ let config = match self {
197
+ Self :: CheckManager => & service_manager. init_config . is_available ,
198
+ Self :: Stop ( _) => & service_manager. init_config . stop ,
199
+ Self :: Restart ( _) => & service_manager. init_config . restart ,
200
+ Self :: Start ( _) => & service_manager. init_config . start ,
201
+ Self :: Enable ( _) => & service_manager. init_config . enable ,
202
+ Self :: Disable ( _) => & service_manager. init_config . disable ,
203
+ Self :: IsActive ( _) => & service_manager. init_config . is_active ,
204
+ } ;
205
+
196
206
match self {
197
- Self :: CheckManager => ExecCommand :: try_new (
198
- service_manager. init_config . is_available . clone ( ) ,
199
- ServiceCommand :: CheckManager ,
200
- config_path,
201
- ) ,
202
- Self :: Stop ( service) => ExecCommand :: try_new_with_placeholder (
203
- service_manager. init_config . stop . clone ( ) ,
204
- ServiceCommand :: Stop ( service) ,
205
- config_path,
206
- service,
207
- ) ,
208
- Self :: Restart ( service) => ExecCommand :: try_new_with_placeholder (
209
- service_manager. init_config . restart . clone ( ) ,
210
- ServiceCommand :: Restart ( service) ,
211
- config_path,
212
- service,
213
- ) ,
214
- Self :: Start ( service) => ExecCommand :: try_new_with_placeholder (
215
- service_manager. init_config . start . clone ( ) ,
216
- ServiceCommand :: Enable ( service) ,
217
- config_path,
218
- service,
219
- ) ,
220
- Self :: Enable ( service) => ExecCommand :: try_new_with_placeholder (
221
- service_manager. init_config . enable . clone ( ) ,
222
- ServiceCommand :: Enable ( service) ,
223
- config_path,
224
- service,
225
- ) ,
226
- Self :: Disable ( service) => ExecCommand :: try_new_with_placeholder (
227
- service_manager. init_config . disable . clone ( ) ,
228
- ServiceCommand :: Disable ( service) ,
229
- config_path,
230
- service,
231
- ) ,
232
- Self :: IsActive ( service) => ExecCommand :: try_new_with_placeholder (
233
- service_manager. init_config . is_active . clone ( ) ,
234
- ServiceCommand :: IsActive ( service) ,
235
- config_path,
236
- service,
237
- ) ,
207
+ Self :: CheckManager => ExecCommand :: try_new ( config. clone ( ) , self , config_path) ,
208
+ Self :: Stop ( service)
209
+ | Self :: Restart ( service)
210
+ | Self :: Start ( service)
211
+ | Self :: Enable ( service)
212
+ | Self :: Disable ( service)
213
+ | Self :: IsActive ( service) => {
214
+ ExecCommand :: try_new_with_placeholder ( config. clone ( ) , self , config_path, service)
215
+ }
238
216
}
239
217
}
240
218
}
0 commit comments