- Timestamp:
- Apr 24, 2008, 1:05:09 AM (14 years ago)
- Location:
- trunk/bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/Parameter.cc
r625 r626 47 47 { 48 48 for (int i=1; i<argc; ++i) { 49 bool ok=false;50 49 std::stringstream ss(argv[i]); 51 50 std::string myargv(""); … … 57 56 if (value.size()) { 58 57 config_file_.value()= value; 59 ok=true;60 58 } 61 59 else if (++i<argc){ 62 60 config_file_.value()= std::string(argv[i]); 63 ok=true; 61 } 62 else { 63 missing_argument(myargv); 64 64 } 65 65 } 66 66 else if (myargv=="--copyright"){ 67 67 copyright_.value()=true; 68 ok=true;69 68 } 70 69 else if (myargv=="-f" || myargv=="--force"){ 71 70 force_.value()=true; 72 ok=true;73 71 } 74 72 else if (myargv=="-g" || myargv=="--generate-config"){ 75 73 generate_config_.value()=true; 76 ok=true;77 74 } 78 75 else if (myargv=="-h" || myargv=="--help"){ … … 82 79 else if (myargv=="--ignore-cache"){ 83 80 ignore_cache_.value()=true; 84 ok=true;85 81 } 86 82 else if (myargv=="-r" || myargv=="--root"){ 87 83 if (value.size()) { 88 84 root_.value()= value; 89 ok=true;90 85 } 91 86 else if (++i<argc){ 92 87 root_.value()= std::string(argv[i]); 93 ok=true; 88 } 89 else { 90 missing_argument(myargv); 94 91 } 95 92 } 96 93 else if (myargv=="--report") { 97 94 report_.value()=true; 98 ok=true;99 95 } 100 96 else if (myargv=="--no-report") { 101 97 report_.value()=false; 102 ok=true;103 98 } 104 99 else if (myargv=="--revisions") { 105 100 revisions_.value()=true; 106 ok=true;107 101 } 108 102 else if (myargv=="-t" || myargv=="--target"){ 109 103 if (value.size()) { 110 104 targetdir_.value()= value; 111 ok=true;112 105 } 113 106 else if (++i<argc){ 114 107 targetdir_.value()= std::string(argv[i]); 115 ok=true; 108 } 109 else { 110 missing_argument(myargv); 116 111 } 117 112 } 118 113 else if (myargv=="-v" || myargv=="--verbose"){ 119 114 verbose_.value()=true; 120 ok=true;121 115 } 122 116 else if (myargv=="--version"){ … … 127 121 verbose_.value()=true; 128 122 force_.value()=true; 129 ok=true; 130 } 131 132 if (!ok) 123 } 124 else { 133 125 throw std::runtime_error("svndigest: invalid option: " + myargv + 134 126 "\nTry `svndigest --help' for usage."); 135 } 127 } 128 } 136 129 137 130 analyse(); … … 241 234 242 235 236 void Parameter::missing_argument(std::string opt) const 237 { 238 if (opt.size()>0 && opt[0]=='-') 239 opt = opt.substr(1); 240 if (opt.size()>0 && opt[0]=='-') 241 opt = opt.substr(1); 242 std::stringstream ss; 243 ss << "svndigest: option requires an argument -- " << opt << "\n" 244 << "Try `svndigest --help' for usage."; 245 throw std::runtime_error(ss.str()); 246 } 247 243 248 void Parameter::version(bool verbose) const 244 249 { -
trunk/bin/Parameter.h
r625 r626 56 56 void analyse(void); 57 57 void help(void) const; 58 void missing_argument(std::string opt) const; 58 59 void version(bool=false) const; 59 60
Note: See TracChangeset
for help on using the changeset viewer.