Changeset 1023 for trunk/bin


Ignore:
Timestamp:
Jan 11, 2010, 12:15:47 AM (12 years ago)
Author:
Peter Johansson
Message:

added new cmd option 'anchor-format'. refs #279

Location:
trunk/bin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/Parameter.cc

    r1017 r1023  
    5151    : cmd_( std::string("Mandatory arguments to long options ") +
    5252            std::string("are mandatory for short options too.")),
     53      anchor_format_(cmd_,"anchor-format",
     54                     "override anchor image format defined in config file"),
    5355      config_file_(cmd_, "config-file",
    5456                   "configuration file [<ROOT>/.svndigest/config]"),
     
    99101  Parameter::~Parameter(void)
    100102  {
     103  }
     104
     105
     106  const yat::utility::OptionArg<std::string>&
     107  Parameter::anchor_format(void) const
     108  {
     109    return anchor_format_;
    101110  }
    102111
     
    231240    // don't use argv[0] because user may rename the binary
    232241    cmd_.program_name() = PACKAGE_NAME;
     242    anchor_format_.print_arg("=FMT");
    233243    config_file_.print_arg("=FILE");
    234244    format_.print_arg("=FMT");
  • trunk/bin/Parameter.h

    r1017 r1023  
    4949    Parameter( int argc, char *argv[]);
    5050    virtual ~Parameter(void);
     51    const yat::utility::OptionArg<std::string>& anchor_format(void) const;
    5152    std::string config_file(void) const;
    5253   
     
    7677
    7778    yat::utility::CommandLine cmd_;
     79    yat::utility::OptionArg<std::string> anchor_format_;
    7880    yat::utility::OptionArg<std::string> config_file_;
    7981    yat::utility::OptionSwitch copyright_;
  • trunk/bin/svndigest.cc

    r1017 r1023  
    4949#include <unistd.h>
    5050
     51void option2config(const theplu::yat::utility::OptionArg<std::string>&,
     52                   void (*FUNC)(const std::string&) );
     53
    5154void create_file_struct(std::string stats_type,
    5255                        const theplu::svndigest::Stats& stats);
     
    9194  }
    9295
     96  // just for convenience
     97  Configuration& conf = Configuration::instance();
    9398  // set values from commandline into config object
    9499  try {
     
    100105              << option->format().value() << "' for `--"
    101106              << option->format().long_name() << "'\n"
     107              << e.what() << "\n"
     108              << "Try `" << PACKAGE_NAME << " --help' for more information.\n";
     109    exit(EXIT_FAILURE);
     110  }
     111  try {
     112    if (option->anchor_format().present())
     113      conf.image_anchor_format(option->anchor_format().value());
     114  }
     115  catch (std::runtime_error& e) {
     116    std::cerr << PACKAGE_NAME ": invalid argument `"
     117              << option->anchor_format().value() << "' for `--"
     118              << option->anchor_format().long_name() << "'\n"
    102119              << e.what() << "\n"
    103120              << "Try `" << PACKAGE_NAME << " --help' for more information.\n";
Note: See TracChangeset for help on using the changeset viewer.