better support for name in options

This commit is contained in:
Love Hornquist Astrand
2010-11-24 16:21:26 -08:00
parent 388341e149
commit 99bc078d46

View File

@@ -126,6 +126,7 @@ check_option(struct assignment *as)
{ {
struct assignment *a; struct assignment *a;
int seen_long = 0; int seen_long = 0;
int seen_name = 0;
int seen_short = 0; int seen_short = 0;
int seen_type = 0; int seen_type = 0;
int seen_argument = 0; int seen_argument = 0;
@@ -138,6 +139,8 @@ check_option(struct assignment *as)
seen_long++; seen_long++;
else if(strcmp(a->name, "short") == 0) else if(strcmp(a->name, "short") == 0)
seen_short++; seen_short++;
else if(strcmp(a->name, "name") == 0)
seen_name++;
else if(strcmp(a->name, "type") == 0) else if(strcmp(a->name, "type") == 0)
seen_type++; seen_type++;
else if(strcmp(a->name, "argument") == 0) else if(strcmp(a->name, "argument") == 0)
@@ -147,7 +150,7 @@ check_option(struct assignment *as)
else if(strcmp(a->name, "default") == 0) else if(strcmp(a->name, "default") == 0)
seen_default++; seen_default++;
else { else {
ex(a, "unknown name"); ex(a, "unknown name %s", a->name);
ret++; ret++;
} }
} }
@@ -155,6 +158,10 @@ check_option(struct assignment *as)
ex(as, "neither long nor short option"); ex(as, "neither long nor short option");
ret++; ret++;
} }
if (seen_long == 0 && seen_name == 0) {
ex(as, "either of long or name option must be used");
ret++;
}
if(seen_long > 1) { if(seen_long > 1) {
ex(as, "multiple long options"); ex(as, "multiple long options");
ret++; ret++;
@@ -209,7 +216,7 @@ check_command(struct assignment *as)
} else if(strcmp(a->name, "max_args") == 0) { } else if(strcmp(a->name, "max_args") == 0) {
seen_maxargs++; seen_maxargs++;
} else { } else {
ex(a, "unknown name"); ex(a, "unknown name: %s", a->name);
ret++; ret++;
} }
} }