1*afb39132SMatt Spinler /** 2*afb39132SMatt Spinler * Copyright © 2017 IBM Corporation 3*afb39132SMatt Spinler * 4*afb39132SMatt Spinler * Licensed under the Apache License, Version 2.0 (the "License"); 5*afb39132SMatt Spinler * you may not use this file except in compliance with the License. 6*afb39132SMatt Spinler * You may obtain a copy of the License at 7*afb39132SMatt Spinler * 8*afb39132SMatt Spinler * http://www.apache.org/licenses/LICENSE-2.0 9*afb39132SMatt Spinler * 10*afb39132SMatt Spinler * Unless required by applicable law or agreed to in writing, software 11*afb39132SMatt Spinler * distributed under the License is distributed on an "AS IS" BASIS, 12*afb39132SMatt Spinler * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*afb39132SMatt Spinler * See the License for the specific language governing permissions and 14*afb39132SMatt Spinler * limitations under the License. 15*afb39132SMatt Spinler */ 16*afb39132SMatt Spinler #include <chrono> 17*afb39132SMatt Spinler #include <iostream> 18*afb39132SMatt Spinler #include "argument.hpp" 19*afb39132SMatt Spinler 20*afb39132SMatt Spinler using namespace witherspoon::power; 21*afb39132SMatt Spinler 22*afb39132SMatt Spinler int main(int argc, char** argv) 23*afb39132SMatt Spinler { 24*afb39132SMatt Spinler ArgumentParser args{argc, argv}; 25*afb39132SMatt Spinler auto action = args["action"]; 26*afb39132SMatt Spinler 27*afb39132SMatt Spinler if (action != "pgood-monitor") 28*afb39132SMatt Spinler { 29*afb39132SMatt Spinler std::cerr << "Invalid action\n"; 30*afb39132SMatt Spinler args.usage(argv); 31*afb39132SMatt Spinler exit(EXIT_FAILURE); 32*afb39132SMatt Spinler } 33*afb39132SMatt Spinler 34*afb39132SMatt Spinler auto i = strtoul(args["interval"].c_str(), nullptr, 10); 35*afb39132SMatt Spinler if (i == 0) 36*afb39132SMatt Spinler { 37*afb39132SMatt Spinler std::cerr << "Invalid interval value\n"; 38*afb39132SMatt Spinler exit(EXIT_FAILURE); 39*afb39132SMatt Spinler } 40*afb39132SMatt Spinler 41*afb39132SMatt Spinler std::chrono::seconds interval{i}; 42*afb39132SMatt Spinler 43*afb39132SMatt Spinler return EXIT_SUCCESS; 44*afb39132SMatt Spinler } 45