| 1 | From rogeeff@mail.com Fri Nov 16 19:57:49 2001 |
|---|
| 2 | Received: 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) |
|---|
| 5 | Received: 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) |
|---|
| 9 | X-eGroups-Return: sentto-1234907-17382-1005929874-ghost=cs.msu.su@returns.groups.yahoo.com |
|---|
| 10 | Received: from [10.1.1.222] by n15.groups.yahoo.com with NNFMP; 16 Nov 2001 16:57:42 -0000 |
|---|
| 11 | X-Sender: rogeeff@mail.com |
|---|
| 12 | X-Apparently-To: boost@yahoogroups.com |
|---|
| 13 | Received: (EGP: mail-8_0_0_1); 16 Nov 2001 16:57:53 -0000 |
|---|
| 14 | Received: (qmail 2553 invoked from network); 16 Nov 2001 16:57:53 -0000 |
|---|
| 15 | Received: from unknown (216.115.97.172) |
|---|
| 16 | by m4.grp.snv.yahoo.com with QMQP; 16 Nov 2001 16:57:53 -0000 |
|---|
| 17 | Received: 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 |
|---|
| 19 | X-eGroups-Return: rogeeff@mail.com |
|---|
| 20 | Received: from [10.1.10.109] by n6.groups.yahoo.com with NNFMP; 16 Nov 2001 16:57:52 -0000 |
|---|
| 21 | To: boost@yahoogroups.com |
|---|
| 22 | Message-ID: <9t3gid+hdf3@eGroups.com> |
|---|
| 23 | In-Reply-To: <E164iu4-00052e-00@zigzag.cs.msu.su> |
|---|
| 24 | User-Agent: eGroups-EW/0.82 |
|---|
| 25 | X-Mailer: eGroups Message Poster |
|---|
| 26 | X-Originating-IP: 199.119.33.162 |
|---|
| 27 | From: "Gennadiy E. Rozental" <rogeeff@mail.com> |
|---|
| 28 | X-Yahoo-Profile: rogeeff |
|---|
| 29 | MIME-Version: 1.0 |
|---|
| 30 | Mailing-List: list boost@yahoogroups.com; contact boost-owner@yahoogroups.com |
|---|
| 31 | Delivered-To: mailing list boost@yahoogroups.com |
|---|
| 32 | Precedence: bulk |
|---|
| 33 | List-Unsubscribe: <mailto:boost-unsubscribe@yahoogroups.com> |
|---|
| 34 | Date: Fri, 16 Nov 2001 16:57:49 -0000 |
|---|
| 35 | Reply-To: boost@yahoogroups.com |
|---|
| 36 | Subject: [boost] Re: arguments parsing, wildcard matcher |
|---|
| 37 | Content-Transfer-Encoding: 7bit |
|---|
| 38 | Content-Type: text/plain; |
|---|
| 39 | charset=US-ASCII |
|---|
| 40 | Content-Length: 5662 |
|---|
| 41 | Status: R |
|---|
| 42 | X-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 |
|---|
| 62 | more |
|---|
| 63 | > elaborated. Moreover, it's almost finished. I planned to announce |
|---|
| 64 | it 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 |
|---|
| 67 | 2 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, |
|---|
| 71 | other |
|---|
| 72 | > ways to accomplish that must be provided, most notable is |
|---|
| 73 | configuration file |
|---|
| 74 | > - library should provide a way to store information from command |
|---|
| 75 | line and |
|---|
| 76 | > config file in a way allowing easy retrieval and using to change |
|---|
| 77 | configurable |
|---|
| 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 | |
|---|
| 85 | Privet, Volodya. |
|---|
| 86 | |
|---|
| 87 | Here what I am looking for to be supported by Command Line Argument |
|---|
| 88 | Framework directly or by means of easy extension: |
|---|
| 89 | |
|---|
| 90 | 1. 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 / |
|---|
| 96 | instead |
|---|
| 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 | |
|---|
| 112 | 2. argument types |
|---|
| 113 | I should be able to explicitle specify expected argument type. For |
|---|
| 114 | example: std::string, int, double, option(bool). The framework should |
|---|
| 115 | perform value validation. For example 1.23 is not valid for int |
|---|
| 116 | argument. The framework should allow to use user-defined classes as |
|---|
| 117 | expected types for command-line argument. In other word. If I provide |
|---|
| 118 | you a class with predefined psecification framework should try to |
|---|
| 119 | generate object of argument class. Some simple extention you can |
|---|
| 120 | provide youself. For example, using following command line you should |
|---|
| 121 | be able to generate std::list<int> |
|---|
| 122 | -values 2 5 7 8 |
|---|
| 123 | and using following command line you should be able to generate |
|---|
| 124 | std::list<std::string> |
|---|
| 125 | -files_to_test test1.td test2.td test3.td test4.td |
|---|
| 126 | and using following command line user should be able to provide |
|---|
| 127 | argument class A to generate std::list<A> |
|---|
| 128 | struct A{ |
|---|
| 129 | std::string key; |
|---|
| 130 | int value; |
|---|
| 131 | }; |
|---|
| 132 | |
|---|
| 133 | -parameters_mapping name1 4 name5 7 name6 8 name9 1123 |
|---|
| 134 | |
|---|
| 135 | 3. argument storage. |
|---|
| 136 | a. Framework should be able to generate and store arguments |
|---|
| 137 | internally. In this case framework in responsable for memory. |
|---|
| 138 | b. Framework should be able to generate and store argument into the |
|---|
| 139 | user-bound location. In this case user in responsable for memory. |
|---|
| 140 | |
|---|
| 141 | 4. arguments can have default values |
|---|
| 142 | |
|---|
| 143 | 5. arguments can be optional and required. The framework should |
|---|
| 144 | automatically check presence of of all required arguments. |
|---|
| 145 | |
|---|
| 146 | 6. argument value access |
|---|
| 147 | a. if user passed storage location - he will be able to get value |
|---|
| 148 | from there |
|---|
| 149 | b. by name and type. If any of them is incorrect - error. The same |
|---|
| 150 | rules aplied here as in 1.h if argument matching algorithm allows |
|---|
| 151 | substrings. |
|---|
| 152 | c. is_present check - to be able to check presence of optional |
|---|
| 153 | arguments. |
|---|
| 154 | |
|---|
| 155 | 7. usage line. |
|---|
| 156 | The framework should be able to generate a using line given a |
|---|
| 157 | difinition of all feilds. To support this you will probably need |
|---|
| 158 | argument description as one of the command line argument |
|---|
| 159 | constructor's argument. Thr framework should be able to configured to |
|---|
| 160 | use different usage line. If command line contain predefined keyword |
|---|
| 161 | (-help or /? for example) framework should print usage message. |
|---|
| 162 | |
|---|
| 163 | 8. Framework Error |
|---|
| 164 | If any of the following condition occures during command line |
|---|
| 165 | processing the framework should generate an error and print a usage |
|---|
| 166 | line: |
|---|
| 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 | |
|---|
| 173 | Invalid name or type should generate exception during value access. |
|---|
| 174 | |
|---|
| 175 | Here my view on the problem. |
|---|
| 176 | |
|---|
| 177 | Regards, |
|---|
| 178 | |
|---|
| 179 | Gennadiy. |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | P.S. Did you look into Brat Appleton's work? It seems to be close to |
|---|
| 183 | what you are doing. |
|---|
| 184 | |
|---|
| 185 | > |
|---|
| 186 | > Concerning your proposal, I can mark two points, apart from it's |
|---|
| 187 | been a |
|---|
| 188 | > subset of mine: |
|---|
| 189 | > 1. It uses get_options(const char* name, type& value) methods, |
|---|
| 190 | which are not |
|---|
| 191 | > extendable (and the similar thing is used in KConfig class in |
|---|
| 192 | KDE....) 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 |
|---|
| 198 | add it to |
|---|
| 199 | > any existing command line parsing library. |
|---|
| 200 | > |
|---|
| 201 | > - Volodya |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | Info: http://www.boost.org Unsubscribe: <mailto:boost-unsubscribe@yahoogroups.com> |
|---|
| 205 | |
|---|
| 206 | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|