canonical / canonical/multipass

Improve the cmd utility function implementation

Open
#3,700 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
9.2k
Forks
828
Avg merge
3d 1h
Merged PRs (30d)
44

Description

**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.

Contributor guide

Open the contributing guide

Research direction

Start by reading Utils::run_cmd_for_output and Utils::run_cmd_for_status, then compare their raw QProcess handling with SimpleProcessSpec, the process factory, and get_arp_output() in macos/backend_utils.cpp. Trace callers of the command helpers and process_throw_on_error/process_log_on_error. Done means command execution uses the newer utility path, failed cases are rethrown consistently, and callers no longer depend on obsolete status handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.