Skip to content

Commit e68f84c

Browse files
authored
Merge pull request #3668 from Bravo555/fix/system-manager-command-fix
fix: wrong message being shown on `system.toml` parse error
2 parents 970cd6f + a5eac7b commit e68f84c

File tree

1 file changed

+19
-41
lines changed

1 file changed

+19
-41
lines changed

crates/core/tedge/src/system_services/managers/general_manager.rs

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -193,48 +193,26 @@ impl ServiceCommand<'_> {
193193
service_manager: &GeneralServiceManager,
194194
) -> Result<ExecCommand, SystemServiceError> {
195195
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+
196206
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+
}
238216
}
239217
}
240218
}

0 commit comments

Comments
 (0)