5 Commits

Author SHA1 Message Date
Phanes
2b2225f3e4 fixed cmakelists 2017-12-05 21:36:00 -05:00
Phanes
6af1082852 branding, legal notices, and improved usage statement 2017-12-05 19:42:53 -05:00
Phanes
9d5af160c5 Merge remote-tracking branch 'origin/master' 2017-12-05 19:26:06 -05:00
Phanes
da50f152f2 fixed merge issue that broke 1.3a release, implemented commandline switches 2017-12-05 19:25:51 -05:00
Chris Punches
7404f07dc5 Update examplar.cpp 2017-12-05 21:39:10 +00:00
3 changed files with 72 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project(ftests) project(examplar)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++1z -O0 -DDEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++1z -O0 -DDEBUG=1")
set(SOURCE_FILES examplar.cpp src/loaders/loaders.cpp src/loaders/loaders.h src/json/jsoncpp.cpp src/loaders/JSON_Loader.cpp src/loaders/JSON_Loader.h src/loaders/helpers.cpp src/loaders/helpers.h src/loaders/Suite.cpp src/loaders/Suite.h src/loaders/Plan.cpp src/loaders/Plan.h src/loaders/Conf.cpp src/loaders/Conf.h src/loaders/Unit.cpp src/loaders/Unit.h src/loaders/Task.cpp src/loaders/Task.h src/sproc/Sproc.cpp src/sproc/Sproc.h) set(SOURCE_FILES examplar.cpp src/loaders/loaders.cpp src/loaders/loaders.h src/json/jsoncpp.cpp src/loaders/JSON_Loader.cpp src/loaders/JSON_Loader.h src/loaders/helpers.cpp src/loaders/helpers.h src/loaders/Suite.cpp src/loaders/Suite.h src/loaders/Plan.cpp src/loaders/Plan.h src/loaders/Conf.cpp src/loaders/Conf.h src/loaders/Unit.cpp src/loaders/Unit.h src/loaders/Task.cpp src/loaders/Task.h src/sproc/Sproc.cpp src/sproc/Sproc.h)
add_executable(ftests ${SOURCE_FILES}) add_executable(examplar ${SOURCE_FILES})

View File

@@ -0,0 +1,20 @@
{
"units": [
{
"name": "A DEFINITION THAT IS NOT USED",
"target": "/usr/bin/dialog --yesno test 50 50",
"rectifier": "/usr/bin/false",
"active": true,
"required": true,
"rectify": true
},
{
"name": "dependent test",
"target": "/usr/bin/false",
"rectifier": "/usr/bin/true",
"active": true,
"required": true,
"rectify": true
}
]
}

View File

@@ -21,20 +21,61 @@
#include <iostream> #include <iostream>
#include "src/json/json.h" #include "src/json/json.h"
#include "src/loaders/loaders.h" #include "src/loaders/loaders.h"
#include <unistd.h>
#include <syslog.h>
/* /*
* TODO Logging -- Pump to syslog with clone to STDOUT
* TODO Unit Files Directory instead of a single Unit File (optional to user)
* TODO Commandline switches * TODO Commandline switches
*/ */
void print_usage()
int main( )
{ {
bool verbose = true; printf("examplar [ -h ] [ -v ] [ -c CONFIG_PATH ]");
exit(0);
}
int main( int argc, char * argv[] )
{
int flags, opt;
bool verbose = false;
bool show_help = false;
std::string config_path = "/etc/Examplar/config.json";
// commandline switches:
// -h help
// -v verbose
// -c CONFIG_FILE_PATH -- defaults to '/etc/Examplar/config.json'
while ( ( opt = getopt( argc, argv, "hvc:" ) ) != -1 )
{
switch(opt)
{
case 'h':
show_help = true;
case 'v':
verbose = true;
break;
case 'c':
config_path = std::string(optarg);
break;
default:
break;
}
}
if ( show_help == true )
{
print_usage();
}
setlogmask( LOG_UPTO( LOG_INFO ) );
openlog( "Examplar", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_PERROR | LOG_LOCAL1 );
// A Plan is made up of Tasks, and a Suite is made up of Units. // A Plan is made up of Tasks, and a Suite is made up of Units.
// A Plan declares what units are executed and a Suite declares the definitions of those units. // A Plan declares what units are executed and a Suite declares the definitions of those units.
Conf configuration = Conf("/home/phanes/development/internal/Examplar/conf/config.json", verbose ); Conf configuration = Conf(config_path, verbose );
// load the configuration file which contains filepaths to definitions of a plan and definitions of units. // load the configuration file which contains filepaths to definitions of a plan and definitions of units.
std::string definitions_file = configuration.get_units_path(); std::string definitions_file = configuration.get_units_path();
@@ -58,8 +99,11 @@ int main( )
catch ( std::exception& e) catch ( std::exception& e)
{ {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
syslog( LOG_ERR, e.what() );
closelog();
return 1; return 1;
} }
closelog();
return 0; return 0;
} }