19 #include "parser_local_proto.h"
21 static void print_cli_flag(FILE *
file,
const char *key,
const char *label,
22 const char *description,
const char *indent);
23 static void print_cli_option(FILE *
file,
const struct Option *opt,
25 static void print_cli_example(FILE *
file,
const char *indent);
27 void print_cli_flag(FILE *
file,
const char *key,
const char *label,
28 const char *description,
const char *indent)
30 fprintf(
file,
"%s**", indent);
33 fprintf(
file,
"-%s**", key);
34 fprintf(
file, MD_NEWLINE);
37 fprintf(
file,
"%s", indent);
40 fprintf(
file, MD_NEWLINE);
43 if (description !=
NULL) {
44 fprintf(
file,
"%s", indent);
50 void print_cli_option(FILE *
file,
const struct Option *opt,
const char *indent)
71 fprintf(
file,
"%s**%s**=", indent, opt->
key);
72 fprintf(
file,
"*%s*", type);
75 fprintf(
file,
"*%s*,...]", type);
79 fprintf(
file,
" **[required]**");
81 fprintf(
file, MD_NEWLINE);
84 fprintf(
file,
"%s", indent);
90 fprintf(
file, MD_NEWLINE);
93 fprintf(
file,
"%s", indent);
99 fprintf(
file, MD_NEWLINE);
101 fprintf(
file,
"%s", indent);
103 fprintf(
file,
"%s: *",
_(
"Allowed values"));
108 if (opt->
def && opt->
def[0] !=
'\0') {
109 fprintf(
file, MD_NEWLINE);
111 fprintf(
file,
"%s", indent);
113 fprintf(
file,
"%s:",
_(
"Default"));
122 while (opt->
opts[i]) {
124 fprintf(
file, MD_NEWLINE);
126 fprintf(
file,
"%s", indent);
127 char *thumbnails =
NULL;
129 if (strcmp(opt->
gisprompt,
"old,colortable,colortable") ==
131 thumbnails =
"colortables";
132 else if (strcmp(opt->
gisprompt,
"old,barscale,barscale") ==
134 thumbnails =
"barscales";
136 "old,northarrow,northarrow") == 0)
137 thumbnails =
"northarrows";
141 fprintf(
file,
" ", opt->
opts[i],
142 thumbnails, opt->
opts[i]);
151 fprintf(
file,
"**: ");
159 void print_cli_example(FILE *
file,
const char *indent)
161 fprintf(
file,
"\n%sExample:\n", indent);
163 fprintf(
file,
"\n%s```sh\n", indent);
164 fprintf(
file,
"%s%s", indent,
st->pgm_name);
166 const struct Option *first_required_rule_option =
172 opt = &
st->first_option;
174 while (opt !=
NULL) {
192 if (opt->
required || first_required_rule_option == opt) {
194 fprintf(
file,
"%s=", opt->
key);
219 fprintf(
file,
"%s", value);
226 fprintf(
file,
"0.0");
237 fprintf(
file,
"\n%s```\n", indent);
249 fprintf(
file,
"%s**%s**", indent,
st->pgm_name);
254 flag = &
st->first_flag;
255 fprintf(
file,
"%s[**-", indent);
256 while (flag !=
NULL) {
257 fprintf(
file,
"%c", flag->
key);
260 fprintf(
file,
"**]");
265 opt = &
st->first_option;
267 while (opt !=
NULL) {
285 fprintf(
file,
"%s", indent);
288 fprintf(
file,
"**%s**=", opt->
key);
289 fprintf(
file,
"*%s*", type);
291 fprintf(
file,
" [,");
292 fprintf(
file,
"*%s*,...]", type);
302 fprintf(
file,
"%s[**--overwrite**]\n", indent);
304 fprintf(
file,
"%s[**--verbose**]\n", indent);
305 fprintf(
file,
"%s[**--quiet**]\n", indent);
306 fprintf(
file,
"%s[**--qq**]\n", indent);
307 fprintf(
file,
"%s[**--ui**]\n", indent);
309 print_cli_example(
file, indent);
322 opt = &
st->first_option;
323 while (opt !=
NULL) {
324 print_cli_option(
file, opt, indent);
326 fprintf(
file, MD_NEWLINE);
332 if (
st->n_flags || new_prompt) {
333 flag = &
st->first_flag;
334 while (
st->n_flags && flag !=
NULL) {
337 fprintf(
file, MD_NEWLINE);
342 print_cli_flag(
file,
"overwrite",
NULL,
343 _(
"Allow output files to overwrite existing files"),
345 fprintf(
file, MD_NEWLINE);
350 print_cli_flag(
file,
"help",
NULL,
_(
"Print usage summary"), indent);
351 fprintf(
file, MD_NEWLINE);
353 print_cli_flag(
file,
"verbose",
NULL,
_(
"Verbose module output"), indent);
354 fprintf(
file, MD_NEWLINE);
356 print_cli_flag(
file,
"quiet",
NULL,
_(
"Quiet module output"), indent);
357 fprintf(
file, MD_NEWLINE);
359 print_cli_flag(
file,
"qq",
NULL,
_(
"Very quiet module output"), indent);
360 fprintf(
file, MD_NEWLINE);
362 print_cli_flag(
file,
"ui",
NULL,
_(
"Force launching GUI dialog"), indent);
void G_free(void *)
Free allocated memory.
void G_free_tokens(char **)
Free memory allocated to tokens.
char * G_chop(char *)
Chop leading and trailing white spaces.
char * G_store(const char *)
Copy string to allocated memory.
char ** G_tokenize(const char *, const char *)
Tokenize string.
int G__uses_new_gisprompt(void)
const struct Option * G__first_required_option_from_rules(void)
void G__md_print_cli_long_version(FILE *file, const char *indent)
void G__md_print_cli_short_version(FILE *file, const char *indent)
void G__md_print_escaped(FILE *f, const char *str)
void G__md_print_escaped_for_options(FILE *f, const char *str)
Structure that stores flag info.
Structure that stores option information.