blob: 0c611b6c2be8470289c8357f862bfcf8b522287a [file] [log] [blame]
Brad Bishop29dbfa62016-12-19 13:39:57 -05001/**
2 * Copyright © 2016 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Patrick Williams3667cf32015-10-20 22:39:11 -050016#include <iostream>
17#include <memory>
Matthew Barth6292aee2016-10-06 10:15:48 -050018#include "argument.hpp"
Brad Bishope55ef3d2016-12-19 09:12:40 -050019#include "mainloop.hpp"
Patrick Williams3667cf32015-10-20 22:39:11 -050020
21static void exit_with_error(const char* err, char** argv)
22{
23 ArgumentParser::usage(argv);
24 std::cerr << std::endl;
25 std::cerr << "ERROR: " << err << std::endl;
26 exit(-1);
27}
28
29int main(int argc, char** argv)
30{
31 // Read arguments.
32 auto options = std::make_unique<ArgumentParser>(argc, argv);
33
34 // Parse out path argument.
35 auto path = (*options)["path"];
36 if (path == ArgumentParser::empty_string)
37 {
38 exit_with_error("Path not specified.", argv);
39 }
40
Vishwanatha Subbanna52b80282016-12-02 23:58:55 +053041 // Finished getting options out, so cleanup the parser.
42 options.reset();
Patrick Williams3667cf32015-10-20 22:39:11 -050043
Brad Bishopd499ca62016-12-19 09:24:50 -050044 MainLoop loop(path);
45 loop.run();
46
47 return 0;
Patrick Williams3667cf32015-10-20 22:39:11 -050048}
49
Brad Bishop03476f12016-12-19 13:09:12 -050050// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4