Changeset 1023
- Timestamp:
- Jan 11, 2010, 12:15:47 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEWS
r1016 r1023 6 6 - Gnuplot replaced with plplot (ticket:97) 7 7 - new option --format (ticket:438) 8 - new option --anchor-format (ticket:279) 8 9 - new section, `[image]`, in config file (ticket:279 and ticket:405) 9 10 - new configure option --with-plplot -
trunk/bin/Parameter.cc
r1017 r1023 51 51 : cmd_( std::string("Mandatory arguments to long options ") + 52 52 std::string("are mandatory for short options too.")), 53 anchor_format_(cmd_,"anchor-format", 54 "override anchor image format defined in config file"), 53 55 config_file_(cmd_, "config-file", 54 56 "configuration file [<ROOT>/.svndigest/config]"), … … 99 101 Parameter::~Parameter(void) 100 102 { 103 } 104 105 106 const yat::utility::OptionArg<std::string>& 107 Parameter::anchor_format(void) const 108 { 109 return anchor_format_; 101 110 } 102 111 … … 231 240 // don't use argv[0] because user may rename the binary 232 241 cmd_.program_name() = PACKAGE_NAME; 242 anchor_format_.print_arg("=FMT"); 233 243 config_file_.print_arg("=FILE"); 234 244 format_.print_arg("=FMT"); -
trunk/bin/Parameter.h
r1017 r1023 49 49 Parameter( int argc, char *argv[]); 50 50 virtual ~Parameter(void); 51 const yat::utility::OptionArg<std::string>& anchor_format(void) const; 51 52 std::string config_file(void) const; 52 53 … … 76 77 77 78 yat::utility::CommandLine cmd_; 79 yat::utility::OptionArg<std::string> anchor_format_; 78 80 yat::utility::OptionArg<std::string> config_file_; 79 81 yat::utility::OptionSwitch copyright_; -
trunk/bin/svndigest.cc
r1017 r1023 49 49 #include <unistd.h> 50 50 51 void option2config(const theplu::yat::utility::OptionArg<std::string>&, 52 void (*FUNC)(const std::string&) ); 53 51 54 void create_file_struct(std::string stats_type, 52 55 const theplu::svndigest::Stats& stats); … … 91 94 } 92 95 96 // just for convenience 97 Configuration& conf = Configuration::instance(); 93 98 // set values from commandline into config object 94 99 try { … … 100 105 << option->format().value() << "' for `--" 101 106 << 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" 102 119 << e.what() << "\n" 103 120 << "Try `" << PACKAGE_NAME << " --help' for more information.\n"; -
trunk/lib/Configuration.cc
r1017 r1023 307 307 } 308 308 else if (lhs == "image_format") { 309 if (rhs!="none" && rhs!="png" && rhs!="svg" && rhs!="pdf") { 310 throw Config_error(line, "unknown format: " + rhs); 311 } 312 image_anchor_format_ = rhs; 309 try { 310 image_anchor_format(rhs); 311 } 312 catch (std::runtime_error e) { 313 throw Config_error(line, 314 "unknown format: " + rhs + "\n" + e.what()); 315 } 313 316 } 314 317 } 315 318 } 316 319 validate_dictionary(); 320 } 321 322 323 void Configuration::image_anchor_format(const std::string& format) 324 { 325 if (format!="none" && format!="pdf" && format!="png" && format!="svg") { 326 std::ostringstream oss; 327 oss << "Valid arguments are:\n" 328 << " - `none'\n" 329 << " - `pdf'\n" 330 << " - `png'\n" 331 << " - `svg'"; 332 throw std::runtime_error(oss.str()); 333 } 334 image_anchor_format_ = format; 317 335 } 318 336 -
trunk/lib/Configuration.h
r1017 r1023 76 76 */ 77 77 const std::string& image_anchor_format(void) const; 78 79 /** 80 \brief set image_anchor_format 81 */ 82 void image_anchor_format(const std::string&); 78 83 79 84 /** -
trunk/test/cmd_format_test.sh
r1022 r1023 32 32 rm -f tmp_stderr 33 33 34 $SVNDIGEST -g --format=svg --anchor-format=svg > tmp_stdout 35 cat tmp_stdout 36 grep 'format = svg' tmp_stdout || exit_fail 37 grep 'anchor_format = svg' tmp_stdout || exit_fail 38 rm -f tmp_stdout 39 34 40 exit_success;
Note: See TracChangeset
for help on using the changeset viewer.