Changeset 1067


Ignore:
Timestamp:
Jun 6, 2010, 4:40:30 AM (13 years ago)
Author:
Peter Johansson
Message:

refs #307. Lift out load of configuration file to common place

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svncopyright.cc

    r1060 r1067  
    2222#include "svncopyrightParameter.h"
    2323
     24#include "main_utility.h"
     25
    2426#include <cassert>
    2527#include <iostream>
     
    4244    return EXIT_FAILURE;
    4345  }
     46
     47  try {
     48    load_config(option.config_file());
     49  }
     50  catch (std::runtime_error& e) {
     51    std::cerr << "svncopyright: " << e.what() << "\n";
     52    return EXIT_FAILURE;
     53  }
     54
    4455  return EXIT_SUCCESS;        // normal exit
    4556}
    46 
  • trunk/bin/svndigest.cc

    r1060 r1067  
    2929#include "Graph.h"
    3030#include "html_utility.h"
     31#include "main_utility.h"
    3132#include "rmdirhier.h"
    3233#include "Stats.h"
     
    7071  }
    7172
    72   // Reading configuration file
     73  try {
     74    load_config(option->config_file());
     75  }
     76  catch (std::runtime_error& e) {
     77    std::cerr << "svndigest: " << e.what() << "\n";
     78    return EXIT_FAILURE;
     79  }
     80
     81  // just for convenience
    7382  Configuration& config = Configuration::instance();
    74   if (node_exist(option->config_file())) {
    75     std::ifstream is(option->config_file().c_str());
    76     if (!is.good()){
    77       is.close();
    78       std::cerr << "\nsvndigest: Cannot open config file "
    79                 << option->config_file() << std::endl;
    80       exit(EXIT_FAILURE);
    81     }
    82     try {
    83       config.load(is);
    84     }
    85     catch (std::runtime_error& e) {
    86       std::cerr << "svndigest: invalid config file\n"
    87                 << e.what() << std::endl;
    88       exit(EXIT_FAILURE);
    89     }
    90     is.close();
    91   }
    92 
    93   // just for convenience
    94   Configuration& conf = Configuration::instance();
    9583  // set values from commandline into config object
    9684  try {
     
    10896  try {
    10997    if (option->anchor_format().present())
    110       conf.image_anchor_format(option->anchor_format().value());
     98      config.image_anchor_format(option->anchor_format().value());
    11199  }
    112100  catch (std::runtime_error& e) {
  • trunk/lib/Makefile.am

    r978 r1067  
    3737  Graph.h \
    3838  HtmlBuf.h HtmlStream.h html_utility.h LineTypeParser.h \
    39   Node.h \
     39  main_utility.h Node.h \
    4040  OptionVersion.h rmdirhier.h \
    4141  Stats.h StatsCollection.h subversion_info.h SVN.h SVNblame.h  \
     
    4747  css.cc Date.cc Directory.cc File.cc first_page.cc\
    4848  Functor.cc Graph.cc HtmlBuf.cc HtmlStream.cc \
    49   html_utility.cc LineTypeParser.cc Node.cc \
     49  html_utility.cc LineTypeParser.cc main_utility.cc Node.cc \
    5050  OptionVersion.cc \
    5151  rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc \
Note: See TracChangeset for help on using the changeset viewer.