diff options
| -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;  } + + +  | 
