/* * Copyright 2011, Oliver Tappe * Distributed under the terms of the MIT License. */ #include "package_repo.h" #include #include #include #include #include extern const char* __progname; const char* kCommandName = __progname; static const char* kUsage = "Usage: %s \n" "Creates or inspects a Haiku package repository file.\n" "\n" "Commands:\n" " create [ ] \n" " Creates a package repository from the information found in \n" " , adding the given package files.\n" "\n" " -C - Change to directory before starting.\n" " -q - be quiet (don't show any output except for errors).\n" " -v - be verbose (list package attributes as encountered).\n" "\n" " list [ ] \n" " Lists the contents of package repository file .\n" "\n" " -v - be verbose (list attributes of all packages found).\n" "\n" " update [ ] \n" " Creates package repository file with all the packages\n" " contained in . If possible, package-infos are\n" " taken from to avoid the need for recomputing the\n" " checksum of all packages.\n" " and can be the same file.\n" "\n" " -C - Change to directory before starting.\n" " -q - be quiet (don't show any output except for errors).\n" " -v - be verbose (list package attributes as encountered).\n" "\n" "Common Options:\n" " -h, --help - Print this usage info.\n" ; void print_usage_and_exit(bool error) { fprintf(error ? stderr : stdout, kUsage, kCommandName); exit(error ? 1 : 0); } int main(int argc, const char* const* argv) { if (argc < 2) print_usage_and_exit(true); const char* command = argv[1]; if (strcmp(command, "create") == 0) return command_create(argc - 1, argv + 1); if (strcmp(command, "list") == 0) return command_list(argc - 1, argv + 1); if (strcmp(command, "update") == 0) return command_update(argc - 1, argv + 1); if (strcmp(command, "help") == 0) print_usage_and_exit(false); else print_usage_and_exit(true); // never gets here return 0; }