aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-21 17:46:46 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-21 17:46:46 -0300
commit2c5a64864f15f3607abf8ae6e1ef02c28bf3144b (patch)
tree7c65cb59ec91f350fd25c59f0111e53eba16126c /src/main.c
parentfa016a15156bf8122b2d3dccaecca53f471d6ecb (diff)
downloadblogc-2c5a64864f15f3607abf8ae6e1ef02c28bf3144b.tar.gz
blogc-2c5a64864f15f3607abf8ae6e1ef02c28bf3144b.tar.bz2
blogc-2c5a64864f15f3607abf8ae6e1ef02c28bf3144b.zip
improved cli argument handling
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index f30a92e..ea4c714 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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