Describe the current situation
The current implementation of Utils::run_cmd_for_output, Utils::run_cmd_for_status is stale, meaning that it still interacts the raw QProcess and it did not handle erroneous cases properly. Nowadays, we have the SimpleProcessSpec utility class and process factory to make process, so we can use these to create a general cmd line run utility function. One template of this can be QString get_arp_output() in macos/backend_utils.cpp. The implementation can generalized and migrated into run_cmd_for_output function, the behavior of the function will change because we rethrow in the failed case. That also means the client code of it might have to adapt.
Furthermore, the run_cmd_for_status may no longer be needed, because the new run_cmd_for_output throws. Besides this, maybe function process_throw_on_error and process_log_on_error can be refactored correspondingly and run_cmd_for_output can be used.
Describe the current situation The current implementation of
Utils::run_cmd_for_output
,Utils::run_cmd_for_status
is stale, meaning that it still interacts the rawQProcess
and it did not handle erroneous cases properly. Nowadays, we have theSimpleProcessSpec
utility class and process factory to make process, so we can use these to create a general cmd line run utility function. One template of this can beQString get_arp_output()
inmacos/backend_utils.cpp
. The implementation can generalized and migrated intorun_cmd_for_output
function, the behavior of the function will change because we rethrow in the failed case. That also means the client code of it might have to adapt.Furthermore, the
run_cmd_for_status
may no longer be needed, because the newrun_cmd_for_output
throws. Besides this, maybe functionprocess_throw_on_error
andprocess_log_on_error
can be refactored correspondingly andrun_cmd_for_output
can be used.