|
| 1 | +/* |
| 2 | + * Copyright (C) 2022 Open Source Robotics Foundation |
| 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 | + |
| 18 | +#include <iostream> |
| 19 | +#include <string> |
| 20 | + |
| 21 | +#include <ignition/utils/cli/CLI.hpp> |
| 22 | + |
| 23 | +#include "sdf/config.hh" |
| 24 | + |
| 25 | +////////////////////////////////////////////////// |
| 26 | +/// \brief Enumeration of available commands |
| 27 | +enum class Command |
| 28 | +{ |
| 29 | + kNone, |
| 30 | +}; |
| 31 | + |
| 32 | +////////////////////////////////////////////////// |
| 33 | +/// \brief Structure to hold all filenames |
| 34 | +struct Options |
| 35 | +{ |
| 36 | + /// \brief Command to execute |
| 37 | + Command command{Command::kNone}; |
| 38 | + |
| 39 | + /// \brief input filename |
| 40 | + std::string inputFilename{"input.usd"}; |
| 41 | + |
| 42 | + /// \brief output filename |
| 43 | + std::string outputFilename{"output.sdf"}; |
| 44 | +}; |
| 45 | + |
| 46 | +void runCommand(const Options &/*_opt*/) |
| 47 | +{ |
| 48 | + // TODO(ahcorde): Call here the USD to SDF converter code |
| 49 | + std::cerr << "USD to SDF conversion is not implemented yet.\n"; |
| 50 | +} |
| 51 | + |
| 52 | +void addFlags(CLI::App &_app) |
| 53 | +{ |
| 54 | + auto opt = std::make_shared<Options>(); |
| 55 | + |
| 56 | + _app.add_option("input", |
| 57 | + opt->inputFilename, |
| 58 | + "Input filename. Defaults to input.usd unless otherwise specified."); |
| 59 | + |
| 60 | + _app.add_option("output", |
| 61 | + opt->outputFilename, |
| 62 | + "Output filename. Defaults to output.sdf unless otherwise specified."); |
| 63 | + |
| 64 | + _app.callback([&_app, opt](){ |
| 65 | + runCommand(*opt); |
| 66 | + }); |
| 67 | +} |
| 68 | + |
| 69 | +////////////////////////////////////////////////// |
| 70 | +int main(int argc, char** argv) |
| 71 | +{ |
| 72 | + CLI::App app{"USD to SDF converter"}; |
| 73 | + |
| 74 | + app.set_help_all_flag("--help-all", "Show all help"); |
| 75 | + |
| 76 | + app.add_flag_callback("--version", [](){ |
| 77 | + std::cout << SDF_VERSION_FULL << std::endl; |
| 78 | + throw CLI::Success(); |
| 79 | + }); |
| 80 | + |
| 81 | + addFlags(app); |
| 82 | + CLI11_PARSE(app, argc, argv); |
| 83 | + |
| 84 | + return 0; |
| 85 | +} |
0 commit comments