This commit is contained in:
parent
ac797e111c
commit
cca3ee9679
@ -176,8 +176,7 @@ bool server_env_manager::run_remote_template_command_and_capture_output(const st
|
|||||||
if (scommand.get_command_to_run().empty())
|
if (scommand.get_command_to_run().empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cMode mode = (silent ? cMode::Silent : cMode::None);
|
cMode mode = cMode::CaptureOutput | cMode::RawCommand;
|
||||||
mode |= cMode::CaptureOutput;
|
|
||||||
return execute_ssh_command(get_SSH_INFO(), scommand, mode, &output);
|
return execute_ssh_command(get_SSH_INFO(), scommand, mode, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,8 @@ bool execute_local_command(const sCommand & command, cMode mode, std::string * o
|
|||||||
|
|
||||||
if (hasFlag(mode, cMode::CaptureOutput)) {
|
if (hasFlag(mode, cMode::CaptureOutput)) {
|
||||||
ASSERT_MSG(output != nullptr, "Capture output mode requires an output string to be provided");
|
ASSERT_MSG(output != nullptr, "Capture output mode requires an output string to be provided");
|
||||||
|
ASSERT_MSG(is_raw(mode), "Capture output mode requires raw command mode");
|
||||||
|
ASSERT_MSG(!hasFlag(mode, cMode::Silent), "Silent mode is not allowed with capture output mode");
|
||||||
|
|
||||||
return execute_local_command_and_capture_output(command, output, mode);
|
return execute_local_command_and_capture_output(command, output, mode);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,22 @@ enum class cMode {
|
|||||||
CaptureOutput = 4,
|
CaptureOutput = 4,
|
||||||
RawCommand = 8
|
RawCommand = 8
|
||||||
};
|
};
|
||||||
|
enum class cStyle {
|
||||||
|
Safe = 0,
|
||||||
|
Raw = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
inline cMode operator&(cMode lhs, cMode rhs) {return static_cast<cMode>(static_cast<int>(lhs) & static_cast<int>(rhs));}
|
||||||
|
inline cMode operator+(cMode lhs, cMode rhs) {return static_cast<cMode>(static_cast<int>(lhs) | static_cast<int>(rhs));}
|
||||||
|
inline cMode operator-(cMode lhs, cMode rhs) {return static_cast<cMode>(static_cast<int>(lhs) & ~static_cast<int>(rhs));}
|
||||||
|
inline cMode operator|(cMode lhs, cMode rhs) {return static_cast<cMode>(static_cast<int>(lhs) | static_cast<int>(rhs));}
|
||||||
|
inline cMode operator|=(cMode & lhs, cMode rhs) {return lhs = lhs | rhs;}
|
||||||
|
inline bool hasFlag(cMode mode, cMode flag) {return (mode & flag) == flag;}
|
||||||
|
inline bool is_safe(cStyle style) { return style == cStyle::Safe; }
|
||||||
|
inline bool is_raw(cStyle style) { return style == cStyle::Raw; }
|
||||||
|
inline bool is_raw(cMode mode) { return hasFlag(mode, cMode::RawCommand); }
|
||||||
|
inline cStyle getStyle(cMode mode) { return is_raw(mode) ? cStyle::Raw : cStyle::Safe; }
|
||||||
|
|
||||||
|
|
||||||
typedef struct sSSHInfo {
|
typedef struct sSSHInfo {
|
||||||
std::string host;
|
std::string host;
|
||||||
@ -31,15 +47,7 @@ std::string makesafecmd(const std::string& command);
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
enum class cStyle {
|
|
||||||
Safe = 0,
|
|
||||||
Raw = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
inline cStyle getStyle(cMode mode) { return is_raw(mode) ? cStyle::Raw : cStyle::Safe; }
|
|
||||||
inline bool is_safe(cStyle style) { return style == cStyle::Safe; }
|
|
||||||
inline bool is_raw(cStyle style) { return style == cStyle::Raw; }
|
|
||||||
inline bool is_raw(cMode mode) { return hasFlag(mode, cMode::RawCommand); }
|
|
||||||
|
|
||||||
// class to hold a command to run on the remote server.
|
// class to hold a command to run on the remote server.
|
||||||
class sCommand {
|
class sCommand {
|
||||||
@ -68,31 +76,6 @@ class sCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Bitwise AND operator for cMode
|
|
||||||
inline cMode operator&(cMode lhs, cMode rhs) {
|
|
||||||
return static_cast<cMode>(
|
|
||||||
static_cast<int>(lhs) & static_cast<int>(rhs)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool hasFlag(cMode mode, cMode flag) {
|
|
||||||
return (mode & flag) == flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline cMode operator-(cMode lhs, cMode rhs) {
|
|
||||||
return static_cast<cMode>(
|
|
||||||
static_cast<int>(lhs) & ~static_cast<int>(rhs)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline cMode operator|(cMode lhs, cMode rhs) {
|
|
||||||
return static_cast<cMode>(static_cast<int>(lhs) | static_cast<int>(rhs));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline cMode operator|=(cMode & lhs, cMode rhs) {
|
|
||||||
return lhs = lhs | rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dropshell
|
} // namespace dropshell
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user