Commit 813937ce by Krzysztof Adamski Committed by Russell Belfer

Better usage info in add example.

parent 24d23220
......@@ -58,6 +58,15 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
return ret;
}
void print_usage(void)
{
fprintf(stderr, "usage: add [options] [--] file-spec [file-spec] [...]\n\n");
fprintf(stderr, "\t-n, --dry-run dry run\n");
fprintf(stderr, "\t-v, --verbose be verbose\n");
fprintf(stderr, "\t-u, --update update tracked files\n");
}
int main (int argc, char** argv)
{
git_index_matched_path_cb matched_cb = NULL;
......@@ -67,11 +76,6 @@ int main (int argc, char** argv)
int i, options = 0;
struct print_payload payload = {0};
if (argc < 2) {
fprintf(stderr, "usage: add [-n|--dry-run] [-v|--verbose] [-u|--update] file-spec [file-spec] [...]\n");
return 1;
}
for (i = 1; i < argc; ++i) {
if (argv[i][0] != '-') {
break;
......@@ -85,22 +89,31 @@ int main (int argc, char** argv)
else if(!strcmp(argv[i], "--update") || !strcmp(argv[i], "-u")) {
options |= UPDATE;
}
else if(!strcmp(argv[i], "-h")) {
print_usage();
break;
}
else if(!strcmp(argv[i], "--")) {
i++;
break;
}
else {
fprintf(stderr, "Unsupported option %s.\n", argv[i]);
print_usage();
return 1;
}
}
init_array(&array, argc-i, argv+i);
printf("args:\n");
for(i=0; i<array.count; i++) {
printf(" - %s\n", array.strings[i]);
if (argc<=i) {
print_usage();
return 1;
}
init_array(&array, argc-i, argv+i);
if (git_repository_open(&repo, ".") < 0) {
fprintf(stderr, "No git repository\n");
return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment