summaryrefslogtreecommitdiff
path: root/src/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.c')
-rw-r--r--src/cli.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/cli.c b/src/cli.c
index 7d00434..3891032 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -34,8 +34,6 @@
" -e, --extract\tExtract the contents of the archive. " \
"This is the default.\n" \
" -l, --list\t\tList the contents of the archive.\n\n" \
- " -a, --archive\tAlternate way of specifying archive" \
- "to extract.\n" \
" -o, --output\t\tPath to extract files to.\n" \
" -g, --game\t\tGame the archive is from. Required for " \
"file decryption\n" \
@@ -68,14 +66,13 @@ struct configuration parse_args(int argc, char *argv[]) {
{"quiet", no_argument, NULL, 'q'},
{"extract", no_argument, NULL, 'e'},
{"list", no_argument, NULL, 'l'},
- {"archive", required_argument, NULL, 'a'},
{"output", required_argument, NULL, 'o'},
{"game", required_argument, NULL, 'g'},
{NULL, 0, NULL, 0}
};
do {
- current = getopt_long(argc, argv, "hvelqa:o:g:", long_options,
+ current = getopt_long(argc, argv, "hvelqo:g:", long_options,
&option_index);
switch (current) {
case 'h':
@@ -90,10 +87,6 @@ struct configuration parse_args(int argc, char *argv[]) {
case 'q':
parsed.quiet = 1;
break;
- case 'a':
- count++;
- parsed.archive = optarg;
- break;
case 'o':
count++;
size_t path_size = strlen(optarg);
@@ -128,15 +121,13 @@ struct configuration parse_args(int argc, char *argv[]) {
count++;
} while (current >= 0);
- /* getopt "sorts" the argument array such that all of the flags come
- first. argv[count] is the first positional argument encountered. */
- if (parsed.archive == NULL) {
- if (argv[count] == NULL) {
- fprintf(stderr, "No archive path provided.\n");
- exit(EXIT_FAILURE);
- }
- parsed.archive = argv[count];
+ /* getopt pushes non-flag arguments to the end of argv, and `count`
+ is only incremented when a flag argument is parsed. */
+ if (count == argc) {
+ fprintf(stderr, "No archive path provided.\n");
+ exit(EXIT_FAILURE);
}
+ parsed.vararg_index = count;
/* The output path is allocated on the heap to simplify freeing. */
if (parsed.output == NULL) {