Changeset 1629
- Timestamp:
- Nov 17, 2008, 10:53:16 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/commandline_test.cc
r1602 r1629 76 76 OptionArg<std::string> dir(cmd, "d,dir", "output directory"); 77 77 OptionHelp help(cmd); 78 OptionSwitch target(cmd, "T,target", "treat DEST as a normal file", true); 78 OptionArg<std::string> target(cmd, "T,target", "treat DEST as a normal file", 79 true, "TARGET"); 79 80 OptionSwitch verbose(cmd, "v,verbose", "explain what is being done"); 80 81 OptionSwitch version(cmd, "version", "output version and exit"); -
trunk/yat/utility/OptionArg.h
r1602 r1629 52 52 \brief Constructor 53 53 54 \param cmd Commandline Option is associated with 55 \param name string such as "help" for --help, "h" for -h or 56 "h,help" for having both short and long option name 57 \param desc string used in help display 58 \param required If true option must be found in commandline or 59 exception is thrown in validation 54 \param cmd Commandline Option is associated with \param name 55 string such as "help" for --help, "h" for -h or "h,help" for 56 having both short and long option name \param desc string used 57 in help display \param required If true option must be found in 58 commandline or exception is thrown in validation \param arg 59 string to be used in help output such as `TARGET' in 60 `--target=TARGET'. See print3(). 60 61 */ 61 62 OptionArg(CommandLine& cmd, std::string name, std::string desc, 62 bool required=false )63 : Option(cmd, name, desc), required_(required) {}63 bool required=false, std::string arg="") 64 : Option(cmd, name, desc), print_arg_(arg), required_(required) {} 64 65 65 66 /** … … 83 84 84 85 private: 86 std::string print_arg_; 85 87 bool required_; 86 88 T value_; … … 155 157 156 158 virtual void do_validate2(void) const {} 159 160 virtual std::string print3(void) const 161 { 162 if (print_arg_.empty()) 163 return std::string(""); 164 return std::string("=")+print_arg_; 165 } 166 157 167 }; 158 168
Note: See TracChangeset
for help on using the changeset viewer.