Changeset 982 for trunk/yat/utility
- Timestamp:
- Oct 22, 2007, 5:26:04 PM (15 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/CommandLine.cc
r981 r982 42 42 namespace utility { 43 43 44 CommandLine::CommandLine(void) 44 CommandLine::CommandLine(std::string str) 45 : description_(str) 45 46 {} 46 47 … … 171 172 std::ostream& operator<<(std::ostream& os, const CommandLine& cmd) 172 173 { 174 os << cmd.description_ << "\n"; 173 175 ColumnStream cs2(os, 2); 174 176 std::string::size_type width = 0; -
trunk/yat/utility/CommandLine.h
r981 r982 55 55 CommandLine cmd; 56 56 OptionArg<std::string> dir(cmd, "d,dir", "output directory"); 57 Option Switch help(cmd, "h,help", "display this help and exit");57 OptionHelp help(cmd); 58 58 OptionSwitch target(cmd, "T,target", "treat DEST as a normal file", true); 59 59 OptionSwitch verbose(cmd, "v,verbose", "explain what is being done"); … … 66 66 return 1; 67 67 } 68 if (help.present()){69 std::cout << "Usage: " << cmd.program_name() << " [OPTION]...\n\n"70 << "This is a test\n\n" << cmd << "\n"71 << "Report bugs to peter@example.net\n";72 exit(0);73 }74 68 if (version.present()){ 75 69 std::cout << cmd.program_name() << " 1.0\n" 76 70 << "Copyright (C) 2007 Peter Johansson\n\n" 77 << "This is free software lsee the source for copying "71 << "This is free software see the source for copying " 78 72 << "conditions. There is NO\nwarranty; not even for " 79 73 << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; … … 100 94 /** 101 95 \brief deafult constructor 96 97 \param str text preceeding the list of option in output 102 98 */ 103 CommandLine( void);99 CommandLine(std::string str="Available options are:"); 104 100 105 101 /** … … 139 135 std::vector<std::string> split(std::string str, char del) const; 140 136 137 std::string description_; 141 138 std::vector<Option*> options_; 142 139 std::map<char, Option*> short_options_; -
trunk/yat/utility/OptionHelp.cc
r981 r982 38 38 { 39 39 usage_ = std::string("Usage: ")+cmd.program_name()+ 40 std::string(" [OPTION]...\n \n");40 std::string(" [OPTION]...\n"); 41 41 } 42 42 … … 45 45 std::vector<std::string>::iterator last) 46 46 { 47 std::cout << usage_ << synopsis_;48 std::cout << cmd() ;47 std::cout << usage_ << "\n" << synopsis_ << "\n"; 48 std::cout << cmd() << "\n"; 49 49 std::cout << post_cmd_; 50 50 exit(0);
Note: See TracChangeset
for help on using the changeset viewer.