diff options
author | Camil Staps | 2016-10-16 19:39:01 +0200 |
---|---|---|
committer | Camil Staps | 2016-10-16 19:39:01 +0200 |
commit | 0092f8927698595dbfc74970cd3e4e8126f5925b (patch) | |
tree | 6dcfc7db0adf9f8dc20520163eb535083d3af50f | |
parent | Minor example updates (diff) |
Usage message when no modules are given
-rw-r--r-- | interpreter/fuspel.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/interpreter/fuspel.c b/interpreter/fuspel.c index bfdbda0..a2b8591 100644 --- a/interpreter/fuspel.c +++ b/interpreter/fuspel.c @@ -51,6 +51,11 @@ struct fuspel *import(struct fuspel *already_parsed, char *fname) { pgm = parse(tokens); free_token_list(tokens); + if (!pgm) { + fprintf(stderr, "Couldn't parse module %s.\n", fname); + exit(EXIT_FAILURE); + } + concat_fuspel(pgm, already_parsed); return pgm; @@ -89,7 +94,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { #endif // _FUSPEL_DEBUG case ARGP_KEY_ARG: env->program = import(env->program, arg); - return 0; + break; + case ARGP_KEY_END: + if (state->arg_num < 1) + argp_usage(state); + break; default: return ARGP_ERR_UNKNOWN; } @@ -109,11 +118,6 @@ int main(int argc, char *argv[]) { #endif argp_parse(&argp, argc, argv, 0, 0, &env); - - if (!env.program) { - fprintf(stderr, "Couldn't parse program.\n"); - exit(EXIT_FAILURE); - } if (env.printProgram) { printf("\n"); |