examples: extract argument conversion helper
diff --git a/examples/args.c b/examples/args.c
index 208c382..533e157 100644
--- a/examples/args.c
+++ b/examples/args.c
@@ -181,3 +181,17 @@ int match_arg_separator(struct args_info *args)
args->pos++;
return 1;
}
+
+void strarray_from_args(git_strarray *array, struct args_info *args)
+{
+ size_t i;
+
+ array->count = args->argc - args->pos;
+ array->strings = calloc(array->count, sizeof(char *));
+ assert(array->strings != NULL);
+
+ for (i = 0; args->pos < args->argc; ++args->pos) {
+ array->strings[i++] = args->argv[args->pos];
+ }
+ args->pos = args->argc;
+}
diff --git a/examples/args.h b/examples/args.h
index 2c68bdb..d626f98 100644
--- a/examples/args.h
+++ b/examples/args.h
@@ -82,4 +82,9 @@ extern int match_bool_arg(int *out, struct args_info *args, const char *opt);
*/
extern int match_arg_separator(struct args_info *args);
+/**
+ * Consume all remaining arguments in a git_strarray
+ */
+extern void strarray_from_args(git_strarray *array, struct args_info *args);
+
#endif