diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-01-05 18:42:14 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-01-05 18:42:14 +0000 |
commit | 277be0d75619db5d3a747318a72d9f14e2e0850c (patch) | |
tree | 702d5c8cb79e41e40737d4a3101a176d4a4e06df | |
parent | Switch to using metadata rather than the @ hack for using XML attributes (diff) | |
download | slicer-277be0d75619db5d3a747318a72d9f14e2e0850c.tar.bz2 slicer-277be0d75619db5d3a747318a72d9f14e2e0850c.tar.xz slicer-277be0d75619db5d3a747318a72d9f14e2e0850c.zip |
Use boost::program_options for cli
-rw-r--r-- | slicer/tool/Jamfile.jam | 3 | ||||
-rw-r--r-- | slicer/tool/slicer.cpp | 30 |
2 files changed, 28 insertions, 5 deletions
diff --git a/slicer/tool/Jamfile.jam b/slicer/tool/Jamfile.jam index de50043..16942a0 100644 --- a/slicer/tool/Jamfile.jam +++ b/slicer/tool/Jamfile.jam @@ -1,5 +1,8 @@ +lib po : : <name>boost_program_options ; + exe slicer : [ glob *.cpp ] : <library>../slicer//slicer + <library>po ; diff --git a/slicer/tool/slicer.cpp b/slicer/tool/slicer.cpp index ce58c57..1a41bcb 100644 --- a/slicer/tool/slicer.cpp +++ b/slicer/tool/slicer.cpp @@ -1,17 +1,37 @@ #include <slicer/parser.h> +#include <boost/program_options.hpp> + +namespace po = boost::program_options; int main(int argc, char ** argv) { - if (argc < 3) { - fprintf(stderr, "slicer <input.ice> <output.cpp>\n"); + boost::filesystem::path slice; + boost::filesystem::path cpp; + + po::options_description opts("Slicer options"); + opts.add_options() + ("help,h", "Show this help message") + ("slice,i", po::value(&slice), "Input ICE Slice file") + ("cpp,o", po::value(&cpp), "Output C++ file"); + + po::positional_options_description p; + p.add("slice", 1); + p.add("cpp", 1); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(opts).positional(p).run(), vm); + po::notify(vm); + + if (vm.count("help") || slice.empty() || cpp.empty()) { + std::cout << opts << std::endl; return 1; } - const boost::filesystem::path slice = argv[1]; - const boost::filesystem::path cpp = argv[2]; - Slicer::Slicer::Apply(slice, cpp); return 0; } + + + |