annotate lwlib/lw_cmdline.h @ 536:33a59e232a5b

Fix basic output target to keep lines below 249 characters The line length limiter in the basic output was not properly moving to the next before 249 characters, which is the limit Color Basic can read in an ASCII basic program. Changed the line limiter to 240 from 247 to account for a possible 5 digit number plus a comma and just a bit of extra breathing space.
author William Astle <lost@l-w.ca>
date Thu, 16 Jun 2022 13:55:34 -0600
parents 8e25147c2aa8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
1 /*
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
2 lw_cmdline.h
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
3
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
4 Copyright © 2010 William Astle
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
5
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
6 This file is part of LWTOOLS.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
7
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
9 terms of the GNU General Public License as published by the Free Software
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
10 Foundation, either version 3 of the License, or (at your option) any later
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
11 version.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
12
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but WITHOUT
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
16 more details.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
17
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
18 You should have received a copy of the GNU General Public License along with
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
19 this program. If not, see <http://www.gnu.org/licenses/>.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
20 */
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
21
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
22 /*
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
23
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
24 This argument parser is patterned after argp from the gnu C library but
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
25 has much of the functionality removed. It is provided here because not
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
26 every system has glibc.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
27
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
28 Most notably, it does not support option groups or i18n.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
29
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
30 */
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
31
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
32 #ifndef ___lw_cmdline_h_seen___
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
33 #define ___lw_cmdline_h_seen___
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
34
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
35 struct lw_cmdline_options
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
36 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
37 char *name;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
38 int key;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
39 char *arg;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
40 int flags;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
41 char *doc;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
42 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
43
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
44 enum
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
45 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
46 lw_cmdline_opt_optional = 1,
192
8ae2670377ca Added hidden options to lw_cmdline
lost@l-w.ca
parents: 5
diff changeset
47 lw_cmdline_opt_hidden = 2,
5
0e01d1343c02 Added basic --help routine to lw_cmdline
lost@l-w.ca
parents: 4
diff changeset
48 /* lw_cmdline_opt_alias = 4,*/
0e01d1343c02 Added basic --help routine to lw_cmdline
lost@l-w.ca
parents: 4
diff changeset
49 /* lw_cmdline_opt_nousage = 0x10,*/
0e01d1343c02 Added basic --help routine to lw_cmdline
lost@l-w.ca
parents: 4
diff changeset
50 lw_cmdline_opt_doc = 0x80
4
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
51 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
52
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
53 enum
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
54 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
55 lw_cmdline_err_unknown = -1
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
56 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
57
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
58 enum
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
59 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
60 lw_cmdline_key_arg = -1,
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
61 lw_cmdline_key_end = 0
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
62 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
63
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
64 struct lw_cmdline_parser
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
65 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
66 struct lw_cmdline_options *options;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
67 int (*parser)(int key, char *arg, void *input);
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
68 char *args_doc;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
69 char *doc;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
70 char *program_version;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
71 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
72
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 192
diff changeset
73 int lw_cmdline_parse(struct lw_cmdline_parser *parser, int argc, char **argv, unsigned flags, int *arg_index, void *input);
4
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
74
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
75 #endif /* ___lw_cmdline_h_seen___ */