1From rogeeff@mail.com Fri Nov 16 19:57:49 2001 2Received: from imap.cs.msu.su (imap.cs.msu.su [158.250.10.15]) 3 by redsun.cs.msu.su (8.9.3/8.9.3) with ESMTP id TAA06515 4 for <ghost@redsun.cs.msu.su>; Fri, 16 Nov 2001 19:59:43 +0300 (MSK) 5Received: from n15.groups.yahoo.com (n15.groups.yahoo.com [216.115.96.65]) 6 by imap.cs.msu.su (8.11.6/8.11.6) with SMTP id fAGGtrd57869 7 for <ghost@cs.msu.su>; Fri, 16 Nov 2001 19:55:54 +0300 (MSK) 8 (envelope-from sentto-1234907-17382-1005929874-ghost=cs.msu.su@returns.groups.yahoo.com) 9X-eGroups-Return: sentto-1234907-17382-1005929874-ghost=cs.msu.su@returns.groups.yahoo.com 10Received: from [10.1.1.222] by n15.groups.yahoo.com with NNFMP; 16 Nov 2001 16:57:42 -0000 11X-Sender: rogeeff@mail.com 12X-Apparently-To: boost@yahoogroups.com 13Received: (EGP: mail-8_0_0_1); 16 Nov 2001 16:57:53 -0000 14Received: (qmail 2553 invoked from network); 16 Nov 2001 16:57:53 -0000 15Received: from unknown (216.115.97.172) 16 by m4.grp.snv.yahoo.com with QMQP; 16 Nov 2001 16:57:53 -0000 17Received: from unknown (HELO n6.groups.yahoo.com) (216.115.96.56) 18 by mta2.grp.snv.yahoo.com with SMTP; 16 Nov 2001 16:57:53 -0000 19X-eGroups-Return: rogeeff@mail.com 20Received: from [10.1.10.109] by n6.groups.yahoo.com with NNFMP; 16 Nov 2001 16:57:52 -0000 21To: boost@yahoogroups.com 22Message-ID: <9t3gid+hdf3@eGroups.com> 23In-Reply-To: <E164iu4-00052e-00@zigzag.cs.msu.su> 24User-Agent: eGroups-EW/0.82 25X-Mailer: eGroups Message Poster 26X-Originating-IP: 199.119.33.162 27From: "Gennadiy E. Rozental" <rogeeff@mail.com> 28X-Yahoo-Profile: rogeeff 29MIME-Version: 1.0 30Mailing-List: list boost@yahoogroups.com; contact boost-owner@yahoogroups.com 31Delivered-To: mailing list boost@yahoogroups.com 32Precedence: bulk 33List-Unsubscribe: <mailto:boost-unsubscribe@yahoogroups.com> 34Date: Fri, 16 Nov 2001 16:57:49 -0000 35Reply-To: boost@yahoogroups.com 36Subject: [boost] Re: arguments parsing, wildcard matcher 37Content-Transfer-Encoding: 7bit 38Content-Type: text/plain; 39 charset=US-ASCII 40Content-Length: 5662 41Status: R 42X-Status: N 43 44--- In boost@y..., Vladimir Prus <ghost@c...> wrote: 45> 46> > Just a couple of classes I wrote that I wondered if anyone thought 47> > any place in boost: 48> > 49> > arguments : simple command-line arguments and options parser: 50> > 51> > class arguments 52> > { 53> > public: 54> > arguments(int argc, char* argv[]); 55> > 56> > bool has_option(const char* name) const; 57> > bool get_option(const char* name, bool& value) const; 58> 59> > Any interest? Already proposed? Wasting my time? 60> 61> Actually, I'm already working on library with the same goals but 62more 63> elaborated. Moreover, it's almost finished. I planned to announce 64it later, 65> but have to do it now. My design goals were: 66> - It should be resonable to use the library to parse as little as 672 command 68> line options. 69> - It must be extandable to privide any resonable handling 70> - since command line is just a way to affect the program behaviour, 71other 72> ways to accomplish that must be provided, most notable is 73configuration file 74> - library should provide a way to store information from command 75line and 76> config file in a way allowing easy retrieval and using to change 77configurable 78> parameters of the program. 79> 80> The docs are available at: 81> http://chronos.cs.msu.su/~ghost/projects/config_db/doc/index.html 82> 83> Let me know what you think. 84 85Privet, Volodya. 86 87Here what I am looking for to be supported by Command Line Argument 88Framework directly or by means of easy extension: 89 901. command line argument formats 91 a. -<one letter key> <value> 92 b. -<one letter key><value> 93 c. -<key> <value> 94 d. -<option> - any length 95 e. /<key> <value> - and all other cases like a,b,c but with / 96instead 97 g. --<key> <value> 98 h. -<key substring> <value> 99 An example: let say you expecting argument -osagent_port 100 then following argument lists should be valid: 101 -o 15000 102 -osa 15000 103 -osagent_port 15000 104 On the other hand it should perform validity checks. For example 105 if you also expect another argument -osagent_host. then first 2 106 argument list above should generate runtime error and 3d should 107 pass. Arguments integrity check should also be performed, i.e. 108 you should not allow for user to define 2 argument like this: 109 "-port" 110 "-port_type" 111 1122. argument types 113 I should be able to explicitle specify expected argument type. For 114example: std::string, int, double, option(bool). The framework should 115perform value validation. For example 1.23 is not valid for int 116argument. The framework should allow to use user-defined classes as 117expected types for command-line argument. In other word. If I provide 118you a class with predefined psecification framework should try to 119generate object of argument class. Some simple extention you can 120provide youself. For example, using following command line you should 121be able to generate std::list<int> 122 -values 2 5 7 8 123and using following command line you should be able to generate 124std::list<std::string> 125 -files_to_test test1.td test2.td test3.td test4.td 126and using following command line user should be able to provide 127argument class A to generate std::list<A> 128struct A{ 129std::string key; 130int value; 131}; 132 133-parameters_mapping name1 4 name5 7 name6 8 name9 1123 134 1353. argument storage. 136 a. Framework should be able to generate and store arguments 137internally. In this case framework in responsable for memory. 138 b. Framework should be able to generate and store argument into the 139user-bound location. In this case user in responsable for memory. 140 1414. arguments can have default values 142 1435. arguments can be optional and required. The framework should 144automatically check presence of of all required arguments. 145 1466. argument value access 147 a. if user passed storage location - he will be able to get value 148from there 149 b. by name and type. If any of them is incorrect - error. The same 150rules aplied here as in 1.h if argument matching algorithm allows 151substrings. 152 c. is_present check - to be able to check presence of optional 153arguments. 154 1557. usage line. 156 The framework should be able to generate a using line given a 157difinition of all feilds. To support this you will probably need 158argument description as one of the command line argument 159constructor's argument. Thr framework should be able to configured to 160use different usage line. If command line contain predefined keyword 161(-help or /? for example) framework should print usage message. 162 1638. Framework Error 164 If any of the following condition occures during command line 165processing the framework should generate an error and print a usage 166line: 167 a. invalid aargument 168 b. ambiguous argument 169 c. invalid value for the argument 170 d. absence of required argument 171 e. framework meet -help (of any other predefined keyword) 172 173Invalid name or type should generate exception during value access. 174 175Here my view on the problem. 176 177Regards, 178 179Gennadiy. 180 181 182P.S. Did you look into Brat Appleton's work? It seems to be close to 183what you are doing. 184 185> 186> Concerning your proposal, I can mark two points, apart from it's 187been a 188> subset of mine: 189> 1. It uses get_options(const char* name, type& value) methods, 190which are not 191> extendable (and the similar thing is used in KConfig class in 192KDE....) What I 193> propose is 194> variables_map vm ..... 195> int i = vm["magic"].as<int>() 196> FontName fn = vm["font"].as<FontName>() 197> 2. You propose wildcard expansions. This is good. But it is easy to 198add it to 199> any existing command line parsing library. 200> 201> - Volodya 202 203 204Info: http://www.boost.org Unsubscribe: <mailto:boost-unsubscribe@yahoogroups.com> 205 206Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 207 208 209 210