Skip to content
Snippets Groups Projects
Commit e9adcf32 authored by Rafael S Castilho's avatar Rafael S Castilho
Browse files

Issue #37: Finished testing uninstalling agent

parent 2c7c581d
No related branches found
No related tags found
2 merge requests!51Merge development to master,!43Issue #37: Finished testing uninstalling agent
Pipeline #
...@@ -8,17 +8,7 @@ ...@@ -8,17 +8,7 @@
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/parsers.hpp> #include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp> #include <boost/program_options/variables_map.hpp>
/* in case we need this for future modifications on the parsing from command line (e.g define print from command line) #include <boost/filesystem/fstream.hpp>
* #include <boost/program_options/cmdline.hpp>
* #include <boost/program_options/environment_iterator.hpp>
* #include <boost/program_options/eof_iterator.hpp>
* #include <boost/program_options/errors.hpp>
* #include <boost/program_options/option.hpp>
* #include <boost/program_options/options_description.hpp>
* #include <boost/program_options/positional_options.hpp>
* #include <boost/program_options/value_semantic.hpp>
* #include <boost/program_options/version.hpp>
*/
#include <sys/utsname.h> #include <sys/utsname.h>
#include <cpr/cpr.h> #include <cpr/cpr.h>
......
...@@ -28,6 +28,7 @@ namespace po = boost::program_options; ...@@ -28,6 +28,7 @@ namespace po = boost::program_options;
namespace asio = boost::asio; namespace asio = boost::asio;
namespace pholders = boost::asio::placeholders; namespace pholders = boost::asio::placeholders;
namespace sys = boost::system; namespace sys = boost::system;
namespace fs = boost::filesystem;
int run_agent(const sys::error_code& /*e*/, pt::ptime begin, bool print ) { int run_agent(const sys::error_code& /*e*/, pt::ptime begin, bool print ) {
pt::ptime now; pt::ptime now;
...@@ -78,7 +79,7 @@ int parse_command_line(int ac, char* av[], int *increment, int *lim, ...@@ -78,7 +79,7 @@ int parse_command_line(int ac, char* av[], int *increment, int *lim,
("help", "produce help message") ("help", "produce help message")
("once", "run agent only once") ("once", "run agent only once")
("print", "set print JSON to true"); ("print", "set print JSON to true");
// ("dummy", "dummy option for testing purpose"); ("uninstall", "uninstall agent and all associated files");
po::variables_map vm; po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm); po::store(po::parse_command_line(ac, av, desc), vm);
...@@ -91,13 +92,18 @@ int parse_command_line(int ac, char* av[], int *increment, int *lim, ...@@ -91,13 +92,18 @@ int parse_command_line(int ac, char* av[], int *increment, int *lim,
if (vm.count("once")) { if (vm.count("once")) {
*lim = 0; *lim = 0;
} }
if (vm.count("print")) { if (vm.count("print")) {
*print = true; *print = true;
} else { } else {
*print = false; *print = false;
} }
return (0); return (0);
if (vm.count("uninstall")) {
fs::remove_all("../../agent");
return (1);
}
return(0);
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment