Skip to content

Commit

Permalink
add output for executed commands
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Dec 31, 2024
1 parent 2da8516 commit 5d4d75d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

## Features
* add "-m" option to "encode" and "decode" commands
* add output for commands executed with "--inject=stop"


# 24.1 (2024-10-27)
Expand Down
17 changes: 11 additions & 6 deletions src/ebusd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,20 @@ int main(int argc, char* argv[], char* envp[]) {
if (arg.find_first_of(' ') != string::npos || arg.find_first_of('/') == string::npos) {
RequestImpl req(false);
req.add(argv[arg_index]);
bool connected;
RequestMode reqMode;
bool connected = true;
RequestMode reqMode = {};
string user;
bool reload;
bool reload = false;
ostringstream ostream;
result_t ret = s_mainLoop->decodeRequest(&req, &connected, &reqMode, &user, &reload, &ostream);
if (ret != RESULT_OK) {
string output = ostream.str();
logError(lf_main, "executing command %s failed: %d", argv[arg_index], output.c_str());
string output = ostream.str();
if (ret != RESULT_OK || output.substr(0, 3) == "ERR" || output.substr(0, 5) == "usage") {
if (output.empty()) {
output = getResultCode(ret);
}
logError(lf_main, "executing command \"%s\" failed: %s", argv[arg_index], output.c_str());
} else if (s_opt.stopAfterInject) {
logNotice(lf_main, "executed command \"%s\": %s", argv[arg_index], output.c_str());
}
continue;
}
Expand Down

0 comments on commit 5d4d75d

Please sign in to comment.