Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2019 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 | #include "argument.hpp" |
| 17 | #include "version.hpp" |
| 18 | |
| 19 | #include <phosphor-logging/log.hpp> |
| 20 | |
| 21 | using namespace phosphor::power; |
| 22 | using namespace phosphor::logging; |
| 23 | |
| 24 | int main(int argc, char** argv) |
| 25 | { |
| 26 | ArgumentParser args{argc, argv}; |
| 27 | auto psuPath = args["get-version"]; |
| 28 | if (psuPath.empty()) |
| 29 | { |
| 30 | log<level::ERR>("PSU Inventory path argument required"); |
| 31 | args.usage(argv); |
| 32 | exit(1); |
| 33 | } |
| 34 | |
| 35 | // For now only get-version is supported |
| 36 | auto version = version::getVersion(psuPath); |
| 37 | printf("%s", version.c_str()); |
| 38 | return version.empty() ? 1 : 0; |
| 39 | } |