From: Mikko Rasa Date: Sun, 19 Oct 2014 13:00:27 +0000 (+0300) Subject: Provide help for datatool's command line options X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0bf1684c1ae0f5ecc23b7c64f0a0fec79a8c2082;p=libs%2Fdatafile.git Provide help for datatool's command line options Also use add_argument instead of the deprecated get_args. --- diff --git a/tool/tool.cpp b/tool/tool.cpp index a82d587..d58853e 100644 --- a/tool/tool.cpp +++ b/tool/tool.cpp @@ -21,16 +21,16 @@ DataTool::DataTool(int argc, char **argv): debug(false) { GetOpt getopt; - getopt.add_option('b', "binary", binary, GetOpt::NO_ARG); - getopt.add_option('c', "compile", compile, GetOpt::NO_ARG); - getopt.add_option('f', "float-size", float_size, GetOpt::REQUIRED_ARG); - getopt.add_option('g', "debug", debug, GetOpt::NO_ARG); - getopt.add_option('o', "output", out_fn, GetOpt::REQUIRED_ARG); - getopt.add_option('p', "pack", pack, GetOpt::NO_ARG); - getopt.add_option('z', "compress", compress, GetOpt::NO_ARG); + getopt.add_option('b', "binary", binary, GetOpt::NO_ARG).set_help("Produce a binary datafile"); + getopt.add_option('c', "compile", compile, GetOpt::NO_ARG).set_help("Create a collection based on a template file"); + getopt.add_option('f', "float-size", float_size, GetOpt::REQUIRED_ARG).set_help("Floating-point precision", "BITS"); + getopt.add_option('g', "debug", debug, GetOpt::NO_ARG).set_help("Display control statements"); + getopt.add_option('o', "output", out_fn, GetOpt::REQUIRED_ARG).set_help("Output to a file instead of stdout", "FILE"); + getopt.add_option('p', "pack", pack, GetOpt::NO_ARG).set_help("Create a pack from multiple files"); + getopt.add_option('z', "compress", compress, GetOpt::NO_ARG).set_help("Produce a compressed datafile"); + getopt.add_argument("infile", in_fns, GetOpt::OPTIONAL_ARG).set_help("Files to process"); getopt(argc, argv); - in_fns = getopt.get_args(); if(in_fns.empty()) in_fns.push_back("-"); @@ -55,7 +55,7 @@ void DataTool::do_transfer() IO::Base *out = open_output(out_fn); DataFile::Writer *writer = create_writer(*out); - for(vector::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i) + for(list::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i) { IO::Base *in = open_input(*i); DataFile::Parser parser(*in, *i); @@ -80,7 +80,7 @@ void DataTool::do_compile() DataFile::Writer *writer = create_writer(*out); Compiler compiler(*writer); - for(vector::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i) + for(list::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i) { IO::Base *in = open_input(*i); DataFile::Parser parser(*in, *i); @@ -95,7 +95,7 @@ void DataTool::do_compile() void DataTool::do_pack() { Packer packer(*this); - for(vector::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i) + for(list::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i) packer.pack_file(*i); packer.create_pack(out_fn); } diff --git a/tool/tool.h b/tool/tool.h index a682d01..e33c954 100644 --- a/tool/tool.h +++ b/tool/tool.h @@ -8,7 +8,7 @@ class DataTool: public Msp::RegisteredApplication { private: - std::vector in_fns; + std::list in_fns; std::string out_fn; bool binary; bool compile;