Skip to content

Commit

Permalink
#249: Implement more config overrides via CLI and upgrade json library
Browse files Browse the repository at this point in the history
  • Loading branch information
shalithasuranga committed Sep 5, 2021
1 parent e99a6b4 commit de3e5a2
Show file tree
Hide file tree
Showing 7 changed files with 2,284 additions and 1,145 deletions.
19 changes: 14 additions & 5 deletions api/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,24 @@ struct tray tray;
bool isTrayCreated = false;

namespace os {
string execCommand(string command, bool shouldCombineErrorStream) {
string execCommand(string command, bool shouldCombineErrorStream,
bool shouldRunInBackground) {
if(shouldCombineErrorStream)
command += " 2>&1";
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)

if(shouldRunInBackground)
command += " &";

std::array<char, 128> buffer;
std::string result = "";
std::shared_ptr<FILE> pipe(popen(command.c_str(), "r"), pclose);
if (!pipe) {
debug::log("ERROR", "Pipe open failed.");
}
else {
while (!feof(pipe.get())) {
if (fgets(buffer.data(), 128, pipe.get()) != nullptr)
else if(!shouldRunInBackground) {
while( !feof(pipe.get())) {
if(fgets(buffer.data(), 128, pipe.get()) != nullptr)
result += buffer.data();
}
}
Expand Down Expand Up @@ -188,7 +193,11 @@ namespace controllers {
json execCommand(json input) {
json output;
string command = input["command"];
output["output"] = os::execCommand(command, true);
bool shouldRunInBackground = false;
if(!input["shouldRunInBackground"].is_null())
shouldRunInBackground = input["shouldRunInBackground"];

output["output"] = os::execCommand(command, true, shouldRunInBackground);
output["success"] = true;
return output;
}
Expand Down
4 changes: 3 additions & 1 deletion api/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace os {
string error;
bool yesButtonClicked = false;
};
string execCommand(string command, bool shouldCombineErrorStream = false);

string execCommand(string command, bool shouldCombineErrorStream = false,
bool shouldRunInBackground = false);
MessageBoxResult showMessageBox(MessageBoxOptions options);

namespace controllers {
Expand Down
Binary file modified bin/neutralino-linux_x64
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/resources/js/neutralino.js

Large diffs are not rendered by default.

Loading

0 comments on commit de3e5a2

Please sign in to comment.