1 | |
---|
2 | Make parse_config_file("foo.cfg", desc) work. |
---|
3 | |
---|
4 | Document handling of positional options which depends on precedding options. |
---|
5 | I.e scanning the parsed options and creating new variables_map when we see |
---|
6 | a positional option. (Email from Tony). |
---|
7 | |
---|
8 | > My instinctive reaction is to provide both via an options argument to |
---|
9 | > split_command_line (a name that would now be more appropriate). But I |
---|
10 | > haven't devoted much time to thinking this through, so I may be wrong. :-) |
---|
11 | > |
---|
12 | > In any event, the tokenization isn't much fun. I'd expect the library to |
---|
13 | > provide a convenient mechanism for parsing a response file. |
---|
14 | |
---|
15 | |
---|
16 | > Similarly, is there some easy to use hook for customizing the "arg" to |
---|
17 | > indicate the type of the data (similar to how the textual representation |
---|
18 | > of the default argument can be changed, e.g. |
---|
19 | > value<Infile>(&forests_file)->default_value(default_in,"STDIN"), so that |
---|
20 | > I could get something like: "-f filename (=STDIN) :" instead of "-f |
---|
21 | > arg (=STDIN) :"? |
---|
22 | |
---|
23 | > A minor nit pick, with option groups (chained options_description), the |
---|
24 | > colons for the same group align but not across groups. |
---|
25 | |
---|
26 | |
---|
27 | There's another possibility: |
---|
28 | |
---|
29 | value<type>(&variable, "filename")->...... |
---|
30 | |
---|
31 | something like that was in the pre-review version, with the difference that the value name was also used to specify flags, e.g "filename?" would mean the value is optional. |
---|
32 | |
---|
33 | |
---|
34 | Should we also store the name specified on the command line in basic_option, |
---|
35 | so that validation_error can mention the *specified* option name? |
---|
36 | |
---|
37 | |
---|
38 | The config file is a bit different from command line. E.g. 'bool_switch' can't |
---|
39 | be specified in the config file. Further, it's not possible to specify a list |
---|
40 | of values in config file. For example, you can't write |
---|
41 | |
---|
42 | include=a,b,c,d |
---|
43 | |
---|
44 | (or some other separator). You need: |
---|
45 | |
---|
46 | include=a |
---|
47 | ... |
---|
48 | include=d |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | > I often find it beneficial to start a log file, by tracing all options |
---|
53 | > in effect. Thus, it would be nice if one could iterate over all values |
---|
54 | > in a variable_map and get a string representation of all values. Perhaps |
---|
55 | > as an iterator range to the original string that was parsed into the |
---|
56 | > value in the first place. Using as<string> delegates to boost::any and |
---|
57 | > only succeeds if the value is indeed a string (a design decision I can |
---|
58 | > only applaud, btw), so I'm out of luck there. |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | UML diagram? |
---|
64 | |
---|
65 | src/cmdline.cpp: function strncmp_nocase(): |
---|
66 | > maybe it can be replaced by something from string_algorithms |
---|
67 | > library. AFAIK the library should be in 1.32. |
---|
68 | |
---|
69 | > 24. the documentation may contain info what source files are needed |
---|
70 | > for which feature or whether they need to be included always all. |
---|
71 | |
---|
72 | The program_options.reference.html may contain one-liner |
---|
73 | overview for every header and every class/typedef/function |
---|
74 | listed here - just for quick browsing and overview. |
---|
75 | |
---|
76 | |
---|
77 | > > > 5. Maybe more overcommented code examples can be added into |
---|
78 | > > > docs, each exploring single feature of library. |
---|
79 | > > > |
---|
80 | > > > Some people learn mostly from such examples. |
---|
81 | > > > |
---|
82 | > > > Later note: definitely would be useful, IMO. |
---|
83 | > > |
---|
84 | > > Maybe. Do you have specific ideas what the examples can be about? |
---|
85 | > |
---|
86 | > One tiny example concentrating on one feature as short/long options, |
---|
87 | > multiple sources, hidden options, positional options, INI handling etc. |
---|
88 | > Something what user can skim over and cut/paste into app. |
---|
89 | |
---|
90 | |
---|
91 | > I would prefer that all occurrences of ASCII be capitalized. It is the |
---|
92 | > abbreviation of the name of the Standard. You may show it in lower case, |
---|
93 | > though, to distinguish "char strings in local 8-bit encoding" from the |
---|
94 | > Standard but it may confuse some readers. I can't think of a good |
---|
95 | > alternative right now. |
---|
96 | |
---|
97 | > [By the way, "positional options" _desperately_ needs an entry in the |
---|
98 | > glossary. It's the most mystifying term in the library.] |
---|
99 | |
---|
100 | > If not already stated, you should note that all options must appear in the |
---|
101 | > options description layer (or class or object). No options may make their |
---|
102 | > first appearance in the runtime configuration file, for instance. The |
---|
103 | > library doesn't like surprises. (I bring this up because other |
---|
104 | > initialization libraries allow an option to be declared in the |
---|
105 | > configuration file alone. The file reader stores the option and parses it |
---|
106 | > to determine its type, for example, Boolean, double, integer or string.) |
---|
107 | |
---|
108 | ----------- |
---|
109 | > "In the simplest case, the name is explicitly specified, which allows the |
---|
110 | > program to decide if such an option is known." |
---|
111 | > |
---|
112 | > or |
---|
113 | > |
---|
114 | > "In the simplest case, the name is explicitly specified and the program |
---|
115 | > decides that the option is known." |
---|
116 | > (This paragraph is a bit hard to read. Maybe when I understand the library |
---|
117 | > better I can suggest some wording which flows more smoothly.) |
---|
118 | |
---|
119 | Maybe some explanation can help. Most of the time, input source contains both |
---|
120 | the name of option and the value, for example, --foo=10. In this case, we |
---|
121 | just lookup the option name, decide we know this option, and process it. |
---|
122 | |
---|
123 | In one specific case -- positional command line options, we don't have |
---|
124 | explicit name. For example: |
---|
125 | |
---|
126 | my_prog 1 2 3 |
---|
127 | |
---|
128 | so more complex logic is necessary. |
---|
129 | |
---|
130 | |
---|
131 | > Rather than clutter up this list it might be better for the word "sources" |
---|
132 | > to be a link to another part of the document which lists the sources and |
---|
133 | > the order of precedence. |
---|
134 | |
---|
135 | Style of 'screen' in docs. |
---|
136 | |
---|
137 | > Perhaps you should include some sample output to show correct and incorrect |
---|
138 | > locale support or include a link to somewhere else in Boost where the |
---|
139 | > reader can find more information. I wouldn't know a Unicode if it came up |
---|
140 | > and bit me on the ankle. |
---|
141 | |
---|
142 | |
---|
143 | > "Common cases are when the value is explicitly specified by the user, and |
---|
144 | > when the value cannot be specified by the user, but the presense of the |
---|
145 | > option implies some value (for example, <code>true</code>). So, the parser |
---|
146 | > checks that the value is specified when needed and not specified when not |
---|
147 | > needed, and returns new (name, value) pair." |
---|
148 | > |
---|
149 | > This wording is quite stiff and I can't decipher it, especially the "not |
---|
150 | > specified when not needed" phrase. Can you rewrite this? |
---|
151 | |
---|
152 | > While I'm thinking about it, can you add the "Last revised..." line at the |
---|
153 | > bottom of each HTML page as it is on program_options.html or it that |
---|
154 | > governed by an xsl file? |
---|
155 | |
---|
156 | > If it doesn't already exist, there should be something in the tutorial to |
---|
157 | > explicitly define the steps required prior to the use of a configuration |
---|
158 | > variable as: |
---|
159 | > 1. declaration |
---|
160 | > 2. addition or composition |
---|
161 | > 3. storage or insertion |
---|
162 | > 4. notification. |
---|
163 | |
---|
164 | |
---|
165 | > I think a few lines should be added to aid the library user with the test |
---|
166 | > programs. You could place them here in howto.xml or elsewhere or in a new |
---|
167 | > section entirely. Users will want to know if their compiler is known to |
---|
168 | > work with the library and should be directed to the Boost Compiler Status |
---|
169 | > Tables page (\status\compiler_status.html or similar) or directly to the |
---|
170 | > Compiler Status Summary (http://boost.sourceforge.net/regression-logs/). |
---|
171 | |
---|
172 | > Many users will want to run the test programs on their own computer. Your |
---|
173 | > documentation should answer these questions: |
---|
174 | > Which libraries must be linked to build the programs? (Dynamic? Static?) |
---|
175 | > Are there any other special considerations or any compiler switches to be |
---|
176 | > set? For those without a full Boost package, which other Boost libraries |
---|
177 | > are "included" by the test programs and, therefore, must be available? |
---|
178 | |
---|
179 | Basically, it's assumed that test programs with be run with Boost.Build. |
---|
180 | Maybe it's worth noting that if a user wants to compiler them himself, |
---|
181 | he should link the program_options library. |
---|
182 | |
---|
183 | > If you decide to make a separate section to describe the implementation of |
---|
184 | > the test programs, you might move the "test_convert" paragraphs starting at |
---|
185 | > line 379 of howto.xml there and put a referring link in its place. |
---|
186 | |
---|
187 | > I thought there was a bit of correspondence on one of the Boost mailing |
---|
188 | > lists concerning the inability of program_options to show the stored |
---|
189 | > variables 'en masse' but I can't find it now. You should include that in |
---|
190 | > the documentation. Most users will be searching for a method to verify that |
---|
191 | > command line and configuration file values were actually stored in place of |
---|
192 | > the default values, for instance. You could put in a line or two stating |
---|
193 | > that there is no one function which will send the entire database to a file |
---|
194 | > for later review. (I think it had something to do with the fact that |
---|
195 | > program_options doesn't "know" the type of each option.) I think it will |
---|
196 | > acquire the status of a Frequently-Asked Question.) |
---|
197 | |
---|
198 | |
---|
199 | > > Agreed. Though it's no FAQ section yet.... maybe, I can add this to howto |
---|
200 | > |
---|
201 | > section, though a question without full solution is not good. |
---|
202 | > |
---|
203 | > For the time being, those who want to know if such a display function |
---|
204 | > exists will have their question answered and the reason for it. I suppose |
---|
205 | > that the library user could insert a series of statements in his program |
---|
206 | > immediately after the "notify" function which would write each known option |
---|
207 | > to a file for later examination. Some people may use a number of "assert" |
---|
208 | > statements instead. They would only come into play in the debug mode. |
---|
209 | |
---|
210 | More visibility for bool_switch. |
---|
211 | |
---|
212 | |
---|
213 | > BTW: I thought of one other comment. One of the things I missed a little |
---|
214 | > in the documentation is a description of the config file format, as well |
---|
215 | > as what can be achieved with the po::command_line_style::style_t enum. I |
---|
216 | > think most users will need this information sooner or later. A few |
---|
217 | > examples would be fine... But then again time is such a precious thing |
---|
218 | |
---|
219 | > Does the library supports sections in config files |
---|
220 | |
---|
221 | > What about the combination of (if some user-settable switch is thrown, |
---|
222 | > but not by default): |
---|
223 | > |
---|
224 | > * allowing unknown options -- these are considered positional parameters |
---|
225 | > * rearranging the argument list such that all positional parameters |
---|
226 | > are moved to the end |
---|
227 | > |
---|
228 | > This way: |
---|
229 | > |
---|
230 | > program --unknown 42 --known-flag --known-arg value |
---|
231 | > |
---|
232 | > is handled as if it were (in standard UNIX command-line-ese): |
---|
233 | > |
---|
234 | > program --known-flag --known-arg value -- --unknown 42 |
---|
235 | |
---|
236 | |
---|