diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-21 17:46:46 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-21 17:46:46 -0300 |
commit | 2c5a64864f15f3607abf8ae6e1ef02c28bf3144b (patch) | |
tree | 7c65cb59ec91f350fd25c59f0111e53eba16126c /src | |
parent | fa016a15156bf8122b2d3dccaecca53f471d6ecb (diff) | |
download | blogc-2c5a64864f15f3607abf8ae6e1ef02c28bf3144b.tar.gz blogc-2c5a64864f15f3607abf8ae6e1ef02c28bf3144b.tar.bz2 blogc-2c5a64864f15f3607abf8ae6e1ef02c28bf3144b.zip |
improved cli argument handling
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -111,13 +111,23 @@ main(int argc, char **argv) listing = true; break; case 't': - if (i + 1 < argc) + if (argv[i][2] != '\0') + template = b_strndup(argv[i] + 2, strlen(argv[i]) - 2); + else if (i + 1 < argc) template = b_strdup(argv[++i]); break; case 'o': - if (i + 1 < argc) + if (argv[i][2] != '\0') + output = b_strndup(argv[i] + 2, strlen(argv[i]) - 2); + else if (i + 1 < argc) output = b_strdup(argv[++i]); break; + default: + blogc_print_usage(); + fprintf(stderr, "blogc: error: invalid argument: -%c\n", + argv[i][1]); + rv = 2; + goto cleanup; } } else |