Vishwanatha Subbanna | 835571e | 2016-11-30 11:29:30 +0530 | [diff] [blame^] | 1 | /** |
| 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 <memory> |
| 19 | #include "argument.hpp" |
| 20 | |
| 21 | static void ExitWithError(const char* err, char** argv) |
| 22 | { |
| 23 | phosphor::led::ArgumentParser::usage(argv); |
| 24 | std::cerr << std::endl; |
| 25 | std::cerr << "ERROR: " << err << std::endl; |
| 26 | exit(-1); |
| 27 | } |
| 28 | |
| 29 | int main(int argc, char** argv) |
| 30 | { |
| 31 | // Read arguments. |
| 32 | auto options = phosphor::led::ArgumentParser(argc, argv); |
| 33 | |
| 34 | // Parse out Name argument. |
| 35 | auto name = std::move((options)["name"]); |
| 36 | if (name == phosphor::led::ArgumentParser::empty_string) |
| 37 | { |
| 38 | ExitWithError("Name not specified.", argv); |
| 39 | } |
| 40 | |
| 41 | // Parse out Name argument. |
| 42 | auto path = std::move((options)["path"]); |
| 43 | if (path == phosphor::led::ArgumentParser::empty_string) |
| 44 | { |
| 45 | ExitWithError("Path not specified.", argv); |
| 46 | } |
| 47 | |
| 48 | return 0; |
| 49 | } |