source: tags/release-0.2/bin/Parameter.cc @ 82

Last change on this file since 82 was 73, checked in by Jari Häkkinen, 18 years ago

Divided Gnuplot class into a basic gnuplot communication class
and a front end class specialized for svnstat.
Added option to plot stats against time or revision.
Removed gnuplot usage of temporary files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1// $Id: Parameter.cc 73 2006-03-04 18:10:07Z jari $
2
3#include "Parameter.h"
4
5#include <iostream>
6#include <stdexcept>
7#include <string>
8
9namespace theplu {
10namespace svnstat {
11
12  Parameter::Parameter(const int argc,const char *argv[])
13  {
14    defaults();
15    for (int i=1; i<argc; i++) {
16      bool ok=false;
17      std::string myargv(argv[i]);
18      if (myargv=="-f" || myargv=="--force"){
19          force_=true;
20          ok=true;
21      }
22      else if (myargv=="-h" || myargv=="--help"){
23        help();
24        exit(0);      // always exit after printing help
25      }
26      else if (myargv=="-r" || myargv=="--root"){
27        if (++i<argc){
28          root_= std::string(argv[i]);
29          ok=true;
30        }
31      }
32      else if (myargv=="-rev" || myargv=="--revisions") {
33          revisions_=true;
34          ok=true;
35      }
36      else if (myargv=="-t" || myargv=="--target"){
37        if (++i<argc){
38          targetdir_= std::string(argv[i]);
39          ok=true;
40        }
41      }
42      else if (myargv=="-v" || myargv=="--verbose"){
43          verbose_=true;
44          ok=true;
45      }
46      else if (myargv=="--version"){
47          version();
48          exit(0);
49      }
50
51      if (!ok)
52        throw std::runtime_error("svnstat: invalid option: " + myargv +
53                                 "\nType 'svnstat --help' for usage.");
54    }
55
56    analyse();
57  }
58
59
60  void Parameter::analyse(void)
61  {
62    // should check that root is a directory
63  }
64
65
66  void Parameter::defaults(void)
67  {
68    force_=false;
69    revisions_=false;
70    root_=".";
71    targetdir_="svnstat_output";
72    verbose_=false;
73  }
74
75
76  void Parameter::help(void)
77  {
78    std::cout << "\n"
79              << "usage: svnstat [options]\n"
80              << "\n"
81              << "svnstat traverses a directory structure (controlled by\n"
82              << "subversion) and calculates developer statistics entries.\n"
83              << "The top level directory of the directory structure to\n"
84              << "traverse is set with the -t option."
85              << "The result is written to a\n"
86              << "sub-directory, svnstat, that is created in the current\n"
87              << "working directory.\n"
88              << "\n"
89              << "Valid options:\n"
90              << "  -f [--force]   : remove target directory/file if it exists\n"
91              << "                   [no force]. NOTE recursive delete.\n"
92              << "  -h [--help]    : display this help and exit\n"
93              << "  -r [--root] arg : svn controlled directory to perform\n"
94              << "                    statistics calculation on [.]\n"
95              << "  -rev [--revisions]: Use revision numbers as time scale\n"
96              << "                      instead of dates [dates].\n"
97              << "  -t [--target] arg : output directory [svnstat_output]\n"
98              << "  -v [--verbose] : explain what is being done\n"
99              << "  --version      : print version information and exit\n"
100              << std::endl;
101  }
102
103
104  void Parameter::version(void)
105  {
106    std::cout << "svnstat 0.1\n"
107              << "Written by Jari Hakkinen and Peter Johansson.\n"
108              << std::endl;
109  }
110
111}} // of namespace wenni and namespace theplu
Note: See TracBrowser for help on using the repository browser.