coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
help.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007-2013 Mike Kinghan, imk@burroingroingjoing.com *
3  * All rights reserved. *
4  * *
5  * Contributed originally by Mike Kinghan, imk@burroingroingjoing.com *
6  * *
7  * Redistribution and use in source and binary forms, with or without *
8  * modification, are permitted provided that the following conditions *
9  * are met: *
10  * *
11  * Redistributions of source code must retain the above copyright *
12  * notice, this list of conditions and the following disclaimer. *
13  * *
14  * Redistributions in binary form must reproduce the above copyright *
15  * notice, this list of conditions and the following disclaimer in the *
16  * documentation and/or other materials provided with the distribution. *
17  * *
18  * Neither the name of Mike Kinghan nor the names of its contributors *
19  * may be used to endorse or promote products derived from this software *
20  * without specific prior written permission. *
21  * *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
29  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
30  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
32  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
33  * DAMAGE. *
34  * *
35  **************************************************************************/
36 
37 #include "help.h"
38 #include "options.h"
39 #include <iostream>
40 #include <cstdlib>
41 
48 using namespace std;
49 
50 void help()
51 {
52  cout << usage() << '\n';
53  exit(EXIT_SUCCESS);
54 }
55 
56 string usage()
57 {
58  return string("usage:\n")
59  + options::prog_name() + " COMMAND [OPTION... [FILE...]]\n"
60  "1. " + options::prog_name() + " { help | --help | -h }\n"
61  "\tDisplay this message and exit.\n"
62  "2. " + options::prog_name() + " { version | --version | -v }\n"
63  "\tDisplay version information and exit.\n"
64  "3. " + options::prog_name() + " source OPTION... [FILE...]\n"
65  "\tSimplify source FILEs in accordance with OPTIONs, "
66  "parsing in the manner of the C preprocessor.\n"
67  "\tInput lines may be dropped from output. Truth functional "
68  "directives may be simplified on output.\n"
69  "4. " + options::prog_name() + " spin OPTION... [FILE...]\n"
70  "\tLike the source command, with all simplified source files "
71  "output beneath a specified directory, mirroring their original "
72  "structure.\n"
73  "5. " + options::prog_name() + " symbols OPTION... [FILE...]\n"
74  "\tList preprocessor symbols from FILEs in accordance with "
75  "OPTIONs, parsing in the manner of the C preprocessor.\n"
76  "6. " + options::prog_name() + " includes OPTION... [FILE...]\n"
77  "\tList #includes fom FILEs in accordance with OPTIONs, parsing in "
78  "the manner of the C preprocessor\n"
79  "7. " + options::prog_name() + " defs OPTION... [FILE...]\n"
80  "\tList #defines and #undefs fom FILEs in accordance with OPTIONs, "
81  "parsing in the manner of the C preprocessor.\n"
82  "8. " + options::prog_name() + " pragmas OPTION... [FILE...]\n"
83  "\tList #pragmas fom FILEs in accordance with OPTIONs, parsing in "
84  "the manner of the C preprocessor\n"
85  "9. " + options::prog_name() + " lines OPTION... [FILE...]\n"
86  "\tList #lines fom FILEs in accordance with OPTIONs, parsing in "
87  "the manner of the C preprocessor\n"
88  "10. " + options::prog_name() + " directives OPTION... [FILE...]\n"
89  "\tList #-directives fom FILEs in accordance with OPTIONs, "
90  "parsing in the manner of the C preprocessor. "
91  "(Directives are #includes, #defines, #undefs, "
92  "#pragmas, #errors, #lines).\n"
93 
94  "General OPTIONS:\n"
95  "\t-fARGFILE, --file ARGFILE\n"
96  "\t\tRead other arguments from ARGFILE.\n"
97  "\t-R, --recurse\n"
98  "\t\tRecurse into directories to find input files.\n"
99  "\t-FEXT1[,EXT2...]\n"
100  "\t--filter EXT1[,EXT2...]\n"
101  "\t\tProcess only input files that have one of the file extensions "
102  "EXT1,EXT2...\n"
103  "\t-DSYM[=VAL], --define SYM[=VAL]\n"
104  "\t\tAssume symbol SYM to be defined [=VAL]\n"
105  "\t-USYM, --undef SYM\n"
106  "\t\tAssume symbol SYM to be undefined.\n"
107  "\t-m, --implicit\n"
108  "\t\tAssume that any symbol that is not --define-ed is implicitly "
109  "--undef-ed.\n"
110  "\t-g{p|i|w|e|a},\n"
111  "\t--gag { progress| info | warning | error | abend }\n"
112  "\t\tSuppress diagnostics no worse than "
113  "{progress | info | warning | error | abend}.\n"
114  "\t-gs, --gag summary\n"
115  "\t\tSuppress summary diagnostics at exit.\n"
116  "\t\t(Default: -gp -gi -gs)\n"
117  "\t-V, --verbose\n"
118  "\t\tOutput all diagnostics.\n"
119  "\t-K, --keepgoing\n"
120  "\t\tIf a parse error is encountered in an input file, continue "
121  "processing subsequent input files.\n"
122  "\t--no-transients\n"
123  "\t\tBy default an in-source #define SYM or #undef SYM directive "
124  "is transiently treated as a -DSYM or -USYM option within the "
125  "source file where it is found. This option suppresses the "
126  "default behaviour at your own risk.\n"
127  "\t-P, --pod\n"
128  "\t\tApart from #-directives, input is Plain Old Data.\n"
129  "\t\tComments and quotations will not be parsed.\n"
130  "\t-E, --eval-wip\n"
131  "\t\tEvaluate constants in the \"work-in-progress\" directives "
132  "\"#if 0\",\"#if 1\". (Default: do not evaluate.)\n"
133  "\t--max-expansion N[K]\n"
134  "\t\tLimit the length of reported macro-expansions "
135  "to N[kilobytes]\n"
136 
137  "source OPTIONs:-\n"
138  "\t-r, --replace\n"
139  "\t\tOverwrite input file with output file. Implied by --recurse\n"
140  "\t\tWith -r, stdin supplies the input *filenames*.\n"
141  "\t\tOtherwise stdin supplies an input *file*; "
142  "the output file is cout.\n"
143  "\t-bSUFFIX, --backup SUFFIX\n"
144  "\t\tBackup each input file by appending SUFFIX to the name.\n"
145  "\t\tApplies only with -r.\n"
146  "\t-kd, --discard drop\n"
147  "\t\tDrop discarded lines from output.\n"
148  "\t-kb, --discard blank\n"
149  "\t\tBlank discarded lines on output.\n"
150  "\t-kc, --discard comment\n"
151  "\t\tComment out discarded lines on output.\n"
152  "\t-xd, --conflict delete\n"
153  "\t\tDelete #defines and #undefs that contradict -D or "
154  "-U options.\n"
155  "\t-xc, --conflict comment\n"
156  "\t\tInsert diagnostic comments on contradictions as per -xd. "
157  "(Default.)\n"
158  "\t-xe, --conflict error\n"
159  "\t\tInsert diagnostic #errors on contradictions as per -xd.\n"
160  "\t--line\n"
161  "\t\tGenerate #line directives to make CPP line-numbering of output"
162  " agree with input even of lines are dropped.\n"
163  "\t-c, --complement\n"
164  "\t\tComplement. Retain the lines that ought to be dropped and "
165  "vice versa.\n"
166  "\t\t(Retained #-directives will still be simplified where "
167  "possible.)\n"
168 
169  "spin OPTIONs:-\n"
170  "\tThe --recurse and --replace options are implied for this "
171  "command.\n"
172  "\t-kd, --discard drop\n"
173  "\t\tDrop discarded lines from output.\n"
174  "\t-kb, --discard blank\n"
175  "\t\tBlank discarded lines on output.\n"
176  "\t-kc, --discard comment\n"
177  "\t\tComment out discarded lines on output.\n"
178  "\t-xd, --conflict delete\n"
179  "\t\tDelete #defines and #undefs that contradict -D or "
180  "-U options.\n"
181  "\t-xc, --conflict comment\n"
182  "\t\tInsert diagnostic comments on contradictions as per -xd. "
183  "(Default.)\n"
184  "\t-xe, --conflict error\n"
185  "\t\tInsert diagnostic #errors on contradictions as per -xd.\n"
186  "\t--line\n"
187  "\t\tGenerate #line directives to make CPP line-numbering of output"
188  " agree with input even of lines are dropped.\n"
189  "\t-c, --complement\n"
190  "\t\tComplement. Retain the lines that ought to be dropped and "
191  "vice versa.\n"
192  "\t\t(Retained #-directives will still be simplified where "
193  "possible.)\n"
194  "\t--dir DIRNAME\n"
195  "\t\tGenerate a spin under directory DIRNAME, which will be "
196  " created if required. Every simplified source file will be output "
197  "to a file with the same name, relative to DIRNAME.\n"
198  "\t-pPATHNAME, --prefix PATHNAME\n"
199  "\t\tIn organizing output files beneath the directory DIRNAME, "
200  "DIRNAME will be equated to the path prefix PATHNAME of any "
201  "input file.\n"
202 
203  "symbols OPTIONs:-\n"
204  "\t-i, --ifs\n"
205  "\t\tList symbols that occur #if[[n]def]/#elif directives.\n"
206  "\t-d, --defs\n"
207  "\t\tList symbols that occur in #define directives.\n"
208  "\t-u, --undefs\n"
209  "\t\tList symbols that occur in #undef directives.\n"
210  "\t--includes\n"
211  "\t\tList symbols that occur in #include directives.\n"
212  "\t--lns\n"
213  "\t\tList symbols that occur in #lines directives.\n"
214  "\t(Default: -i -d -u --includes --lns)\n"
215  "\t-o, --once-only\n"
216  "\t\tList only the first occurrence of of each distinct "
217  "reference a symbol\n"
218  "\t--once-per_file\n"
219  "\t\tList only the first occurrence per file of of each distinct "
220  "reference of a symbol\n"
221  "\t-A, --active\n"
222  "\t\tList only symbols from operative directives\n"
223  "\t-I, --inactive\n"
224  "\t\tList only symbols from inoperative directives\n"
225  "\t-L, --locate\n"
226  "\t\tReport the source file and line number of each listed "
227  "occurrence.\n"
228  "\t-e, --expand\n"
229  "\t\tReport the expansion of each symbol reference and "
230  "its resolved value, if any\n"
231  "\t--explain\n"
232  "\t\tReport the progressive expansion of each symbol "
233  "reference and its resolved value, if any. "
234  "Implies --expand.\n"
235  "\t--select=NAME1[*][,NAME2[*]...]\n"
236  "\t\tReport only on symbols that match one of the optionally "
237  "wildcard-terminated names\n"
238 
239  "includes OPTIONs:-\n"
240  "\t-s, --system\n"
241  "\t\tList system headers, i.e. <header.h>\n"
242  "\t-L, --local\n"
243  "\t\tList local headers, i.e. \"header.h\"\n"
244  "\t(Default: -s -L)\n"
245  "\t-o, --once-only\n"
246  "\t\tList only the first occurrence of each header. "
247  "\t--once-per-file\n"
248  "\t\tList only the first occurrence per file of each header\n"
249  "\t-A --active\n"
250  "\t\tList only headers from operative directives.\n"
251  "\t-I --inactive\n"
252  "\t\tList only headers from inoperative directives.\n"
253  "\t-L, --locate\n"
254  "\t\tReport the source file and line number of each listed "
255  "occurrence.\n"
256 
257  "defs OPTIONs:-\n"
258  "\t-o, --once-only\n"
259  "\t\tList only the first occurrence of each distinct #define or "
260  "#undef directive\n"
261  "\t--once-per-file\n"
262  "\t\tList only the first occurrence per file of each distinct "
263  "#define or #undef directive\n"
264  "\t-A --active\n"
265  "\t\tList only operative #define and #undef directives.\n"
266  "\t-I --inactive\n"
267  "\t\tList only inoperative #define and #undef directives.\n"
268  "\t-L, --locate\n"
269  "\t\tReport the source file and line number of each listed "
270  "occurrence.\n"
271 
272  "pragmas OPTIONs:-\n"
273  "\t-o, --once-only\n"
274  "\t\tList only the first occurrence of each distinct pragma\n"
275  "\t--once-per-file\n"
276  "\t\tList only the first occurrence per file of each distinct "
277  "pragma\n"
278  "\t-A, --active\n"
279  "\t\tList only pragmas from lines that are retained.\n"
280  "\t-I, --inactive\n"
281  "\t\tList only pragmas from lines that are dropped.\n"
282  "\t-L, --locate\n"
283  "\t\tReport the source file and line number of each listed "
284  "occurrence.\n"
285 
286  "errors OPTIONs:-\n"
287  "\t-o, --once-only\n"
288  "\t\tList only the first occurrence of each #error directive\n"
289  "\t--once-per-file\n"
290  "\t\tList only the first occurrence per file of each "
291  "#error directive\n"
292  "\t-A, --active\n"
293  "\t\tList only operative #error directives.\n"
294  "\t-I, --inactive\n"
295  "\t\tList only inoperative #error directives.\n"
296  "\t-L, --locate\n"
297  "\t\tReport the source file and line number of each listed "
298  "occurrence.\n"
299 
300  "lines OPTIONs:-\n"
301  "\t-o, --once-only\n"
302  "\t\tList only the first occurrence of each #line directive\n"
303  "\t--once-per-file\n"
304  "\t\tList only the first occurrence per file of each "
305  "#line directive\n"
306  "\t-A, --active\n"
307  "\t\tList only operative #line directives.\n"
308  "\t-I, --inactive\n"
309  "\t\tList only inoperative #line directives.\n"
310  "\t-L, --locate\n"
311  "\t\tReport the source file and line number of each listed "
312  "occurrence.\n"
313 
314  "directives OPTIONs:-\n"
315  "\t-o, --once-only\n"
316  "\t\tList only the first occurrence of each distinct directive\n"
317  "\t--once-per-file\n"
318  "\t\tList only the first occurrence per file of each distinct "
319  "directive\n"
320  "\t-A, --active\n"
321  "\t\tList only operative directives.\n"
322  "\t-I, --inactive\n"
323  "\t\tList only inoperative directives.\n"
324  "\t-L, --locate\n"
325  "\t\tReport the source file and line number of each listed "
326  "occurrence.";
327 }
328 
329 // EOF
330 
string usage()
Get program usage summary in a string.
Definition: help.cpp:56
void help()
Write brief command usage information to cout.
Definition: help.cpp:50
static std::string const & prog_name()
Get the program's name.
Definition: options.h:97