aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@inria.fr>2026-07-12 10:26:01 +0200
committerTristan Riehs <tristan.riehs@inria.fr>2026-07-12 10:26:01 +0200
commit2fb55a9582536ee85a1912d76fd4d359fa3c8555 (patch)
tree8fe4e7a0c7534871cab2c8844efdec925dd3d776 /src
parente080f1f6b89d4f5960ac2c45029dd91045fb75ed (diff)
Use getopt for ftag export
Diffstat (limited to 'src')
-rw-r--r--src/main.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index 34dbb61..cfc1c18 100644
--- a/src/main.c
+++ b/src/main.c
@@ -188,9 +188,9 @@ static void ftag_file_get_path(char *out, int size, const char *file)
static void ftag_export(int argc, char **argv)
{
- /* TODO: use getopt here */
- while ((argc > 0) && (argv[0][0] == '-')) {
- switch (argv[0][1]) {
+ int opt;
+ while ((opt = getopt(argc, argv, "h")) != -1) {
+ switch (opt) {
case 'h':
ftag_export_help();
exit(EXIT_SUCCESS);
@@ -198,15 +198,13 @@ static void ftag_export(int argc, char **argv)
ftag_export_usage();
exit(EXIT_FAILURE);
}
- argv++;
- argc--;
}
- if (argc != 2) {
+ if (argc - optind != 1) {
ftag_export_help();
exit(EXIT_FAILURE);
}
- char *archive_dir = argv[1];
+ char *archive_dir = argv[optind];
char archive_file[64];
strbuild(archive_file, "%s%s", archive_dir, ".tar.gz");