diff --git a/cli/main.cpp b/cli/main.cpp index 7255980..61425a3 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -1031,10 +1031,26 @@ std::vector toLegacyDeviceList(std::vector& device return legacy; } +// Whether this invocation was asked to set something. +bool hasRequestedAction(const std::vector& devices) +{ + for (const auto& dev : devices) { + for (const auto& req : dev.feature_requests) { + if (req.type == CAPABILITYTYPE_ACTION && req.should_process) { + return true; + } + } + } + + return false; +} + // Enable info requests for extended output formats (JSON, YAML, ENV) +// Only for a pure query: the extra reads can cost far more than the action +// itself (Maxwell 2: -s 20 is 0.07 s, -s 20 -o json is 2.90 s). void enableExtendedInfoRequests(std::vector& devices, bool extended) { - if (!extended) + if (!extended || hasRequestedAction(devices)) return; for (auto& dev : devices) {