Changeset 1015 for trunk


Ignore:
Timestamp:
Jan 9, 2010, 3:16:03 PM (14 years ago)
Author:
Peter Johansson
Message:

closes #438. adding an option --format

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r1010 r1015  
    55Version 0.8 (released NOT YET)
    66  - Gnuplot replaced with plplot (ticket:97)
     7  - new option --format (ticket:438)
    78  - new configure option --with-plplot
    89  - new default codon for `*.as` in config file
  • trunk/bin/Parameter.cc

    r978 r1015  
    6363                    std::string("ignore cache files and analyze ") +
    6464                    std::string("everything from repository")),
     65      format_(cmd_,"format", "override image format defined in config file"),
    6566      report_(cmd_, "report", "create no HTML report", true),
    6667      revisions_(cmd_, "revisions",
     
    219220
    220221
     222  const yat::utility::OptionArg<std::string>&
     223  Parameter::format(void) const
     224  {
     225    return format_;
     226  }
     227
     228
    221229  void Parameter::init(void)
    222230  {
     
    224232    cmd_.program_name() = PACKAGE_NAME;
    225233    config_file_.print_arg("=FILE");
     234    format_.print_arg("=FMT");
    226235    root_.print_arg("=ROOT");
    227236    target_.print_arg("=TARGET");
  • trunk/bin/Parameter.h

    r978 r1015  
    5555    bool generate_config(void) const ;
    5656    bool ignore_cache(void) const;
     57    const yat::utility::OptionArg<std::string>& format(void) const;
    5758    bool report(void) const;
    5859    bool revisions(void) const;
     
    8182    yat::utility::OptionHelp help_;
    8283    yat::utility::OptionSwitch ignore_cache_;
     84    yat::utility::OptionArg<std::string> format_;
    8385    yat::utility::OptionSwitch report_;
    8486    yat::utility::OptionSwitch revisions_;
  • trunk/bin/svndigest.cc

    r978 r1015  
    3737
    3838#include "yat/Exception.h"
     39#include "yat/OptionArg.h"
    3940
    4041#include <cassert>
     
    8182      config.load(is);
    8283    }
    83     catch (std::runtime_error e) {
     84    catch (std::runtime_error& e) {
    8485      std::cerr << "svndigest: invalid config file\n"
    8586                << e.what() << std::endl;
     
    8788    }
    8889    is.close();
     90  }
     91
     92  // set values from commandline into config object
     93  try {
     94    if (option->format().present())
     95      Configuration::instance().image_format(option->format().value());
     96  }
     97  catch (std::runtime_error& e) {
     98    std::cerr << PACKAGE_NAME ": invalid argument `"
     99              << option->format().value() << "' for `--"
     100              << option->format().long_name() << "'\n"
     101              << e.what() << "\n"
     102              << "Try `" << PACKAGE_NAME << " --help' for more information.\n";
     103    exit(EXIT_FAILURE);
    89104  }
    90105 
  • trunk/lib/Configuration.cc

    r1011 r1015  
    297297      else if (section == "image") {
    298298        if (lhs == "format") {
    299           if (rhs!="none" && rhs!="png" && rhs!="svg") {
    300             throw Config_error(line, "unknown format: " + rhs);
     299          try {
     300            image_format(rhs);
    301301          }
    302           image_format_ = rhs;
     302          catch (std::runtime_error e) {
     303            throw Config_error(line,
     304                               "unknown format: " + rhs + "\n" + e.what());
     305          }
    303306        }
    304307        else if (lhs == "image_format") {
     
    311314    }
    312315    validate_dictionary();
     316  }
     317
     318
     319  void Configuration::image_format(const std::string& format)
     320  {
     321    if (format!="none" && format!="png" && format!="svg") {
     322      std::ostringstream oss;
     323      oss << "Valid arguments are:\n"
     324          << "  - `none'\n"
     325          << "  - `png'\n"
     326          << "  - `svg'";
     327      throw std::runtime_error(oss.str());
     328    }
     329    image_format_ = format;
    313330  }
    314331
  • trunk/lib/Configuration.h

    r996 r1015  
    8080     */
    8181    const std::string& image_format(void) const;
     82
     83    /**
     84       \brief set image_format
     85     */
     86    void image_format(const std::string&);
    8287
    8388    ///
  • trunk/test/Makefile.am

    r991 r1015  
    2828
    2929distributed_TESTS =
     30distributed_TESTS += cmd_format_test.sh
    3031distributed_TESTS += config2_test.sh
    3132distributed_TESTS += copyright2_test.sh
  • trunk/test/config2_test.sh

    r971 r1015  
    2929$SVNDIGEST -g --config-file $srcdir/../.svndigest/config || exit_fail
    3030
     31cat > tmp_config <<EOF
     32#
     33[image]
     34format = apple
     35EOF
     36
     37$SVNDIGEST -g --config-file tmp_config 2> tmp_stderr && exit_fail
     38grep 'unknown format.* apple' tmp_stderr || exit_fail
     39rm -f tmp_stderr tmp_config
    3140exit_success
  • trunk/test/repo_test.sh

    r978 r1015  
    2525. ./init.sh || exit 1
    2626
    27 $mkdir_p $targetdir;
    28 
    2927$SVNDIGEST -r $rootdir -t $targetdir --ignore-cache --no-report || exit_fail;
    3028
Note: See TracChangeset for help on using the changeset viewer.