[fix] Print usage info on -h/--help to libpostal cli
This commit is contained in:
21
src/main.c
21
src/main.c
@@ -5,16 +5,31 @@
|
||||
|
||||
#include "libpostal.h"
|
||||
#include "log/log.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
#define LIBPOSTAL_USAGE "Usage: ./libpostal address [language ...]\n"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
char *arg;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
arg = argv[i];
|
||||
if (string_equals(arg, "-h") || string_equals(arg, "--help")) {
|
||||
printf(LIBPOSTAL_USAGE);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc < 3) {
|
||||
log_error("Usage: test_libpostal string languages...\n");
|
||||
log_error(LIBPOSTAL_USAGE);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
char *str = argv[1];
|
||||
char *languages[argc - 2];
|
||||
for (int i = 0; i < argc - 2; i++) {
|
||||
char *arg = argv[i + 2];
|
||||
for (i = 0; i < argc - 2; i++) {
|
||||
arg = argv[i + 2];
|
||||
if (strlen(arg) >= MAX_LANGUAGE_LEN) {
|
||||
printf("arg %d was longer than a language code (%d chars). Make sure to quote the input string\n", i + 2, MAX_LANGUAGE_LEN - 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user