Changeset 116 for trunk/bin/Parameter.cc


Ignore:
Timestamp:
Jun 30, 2006, 2:04:54 PM (15 years ago)
Author:
Peter Johansson
Message:

fixes #48 #49

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/Parameter.cc

    r106 r116  
    2323
    2424#include "Parameter.h"
     25#include "utility.h"
    2526#include <config.h> // this header file is created by configure
    2627
     
    5051        if (++i<argc){
    5152          root_= std::string(argv[i]);
    52           // if last character is '/' remove
    53           if (*root_.rbegin()=='/')
    54             root_.erase(root_.begin()+root_.size()-1);
    5553          ok=true;
    5654        }
     
    6361        if (++i<argc){
    6462          targetdir_= std::string(argv[i]);
    65           // if last character is '/' remove
    66           if (*targetdir_.rbegin()=='/')
    67             targetdir_.erase(targetdir_.begin()+targetdir_.size()-1);
    6863          ok=true;
    6964        }
     
    8984  void Parameter::analyse(void)
    9085  {
     86
    9187    struct stat buf;
    9288    // check that root directory exists
     
    9995                               ": No such directory.");
    10096    }
     97     
     98    // making root absolute
     99    std::string workdir(pwd());
     100    chdir(root_.c_str());
     101    root_ = pwd();
     102    // remove trailing '/'
     103    if (*root_.rbegin()=='/')
     104      root_.erase(root_.begin()+root_.size()-1);
     105
     106    // making targetdir absolute
     107    chdir(targetdir_.c_str());
     108    targetdir_ = pwd();
     109    // remove trailing '/'
     110    if (*targetdir_.rbegin()=='/')
     111      root_.erase(targetdir_.begin()+targetdir_.size()-1);
     112
     113    chdir(workdir.c_str());
     114
    101115  }
    102116
     
    114128  void Parameter::help(void)
    115129  {
     130    defaults();
    116131    std::cout << "\n"
    117132              << "usage: svnstat [options]\n"
     
    120135              << "subversion) and calculates developer statistics entries.\n"
    121136              << "The top level directory of the directory structure to\n"
    122               << "traverse is set with the -t option."
    123               << "The result is written to a\n"
    124               << "sub-directory, svnstat, that is created in the current\n"
    125               << "working directory.\n"
     137              << "traverse is set with the -r option. The result is written to\n"
     138              << "the current working directory or a directory set with the\n"
     139              << "-t option.\n"
    126140              << "\n"
    127141              << "Valid options:\n"
     
    130144              << "  -h [--help]    : display this help and exit\n"
    131145              << "  -r [--root] arg : svn controlled directory to perform\n"
    132               << "                    statistics calculation on [.]\n"
     146              << "                    statistics calculation on ["
     147              << root_ << "]\n"
    133148              << "  -rev [--revisions]: Use revision numbers as time scale\n"
    134149              << "                      instead of dates [dates].\n"
    135               << "  -t [--target] arg : output directory [.]\n"
     150              << "  -t [--target] arg : output directory ["
     151              << targetdir_ << "]\n"
    136152              << "  -v [--verbose] : explain what is being done\n"
    137153              << "  --version      : print version information and exit\n"
Note: See TracChangeset for help on using the changeset viewer.