blob: 671b73c8f966456eb150d9df366d3bc3b8fc0a2a [file] [log] [blame]
Vishwanatha Subbannaaffea8b2017-04-04 14:02:16 +05301/**
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 */
16
17#include <iostream>
18#include <string>
19#include "argument.hpp"
20
21static void exitWithError(const char* err, char** argv)
22{
23 phosphor::gpio::ArgumentParser::usage(argv);
24 std::cerr << "ERROR: " << err << "\n";
25 exit(EXIT_FAILURE);
26}
27
28int main(int argc, char** argv)
29{
30 // Read arguments.
31 auto options = phosphor::gpio::ArgumentParser(argc, argv);
32
33 // Parse out path argument.
34 auto path = (options)["path"];
35 if (path == phosphor::gpio::ArgumentParser::emptyString)
36 {
37 exitWithError("path not specified.", argv);
38 }
39
40 // Parse out key number that we are interested in
41 // Its integer mapping to the GPIO key configured by the kernel
42 auto key = (options)["key"];
43 if (key == phosphor::gpio::ArgumentParser::emptyString)
44 {
45 exitWithError("Key not specified.", argv);
46 }
47 // TODO : Convert key to integer
48
49 // Parse out assertion polarity interested in
50 // Its either 1 or 0 for press / release
51 auto polarity = (options)["polarity"];
52 if (polarity == phosphor::gpio::ArgumentParser::emptyString)
53 {
54 exitWithError("Polarity not specified.", argv);
55 }
56 // TODO : Convert polarity to integer
57
58 // Parse out target argument. It is fine if the caller does not
59 // pass this if they are not interested in calling into any target
60 // on meeting a condition.
61 auto target = (options)["target"];
62
63 return 0;
64}