create_repository_config: Make URL argument optional
If not specified, the URL from the repository info is used.
This commit is contained in:
parent
12c19e6362
commit
1221b67d07
@ -37,10 +37,11 @@ void
|
||||
print_usage_and_exit(bool error)
|
||||
{
|
||||
fprintf(error ? stderr : stdout,
|
||||
"Usage: %s <URL> <repository info> <repository config>\n"
|
||||
"Creates a repository config file from a given base URL (the\n"
|
||||
"directory in which the \"repo\", \"repo.info\', and \"repo.sha256\n"
|
||||
"files can be found.\n",
|
||||
"Usage: %s [ <URL> ] <repository info> <repository config>\n"
|
||||
"Creates a repository config file from a given repository info and\n"
|
||||
"the base URL (the directory in which the \"repo\", \"repo.info\',\n"
|
||||
"and \"repo.sha256 files can be found). If the URL is not specified,\n"
|
||||
"the one from the repository info is used.",
|
||||
sProgramName);
|
||||
exit(error ? 1 : 0);
|
||||
}
|
||||
@ -49,7 +50,7 @@ print_usage_and_exit(bool error)
|
||||
int
|
||||
main(int argc, const char* const* argv)
|
||||
{
|
||||
if (argc != 4) {
|
||||
if (argc < 3 || argc > 4) {
|
||||
if (argc == 2
|
||||
&& (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) {
|
||||
print_usage_and_exit(false);
|
||||
@ -57,15 +58,19 @@ main(int argc, const char* const* argv)
|
||||
print_usage_and_exit(true);
|
||||
}
|
||||
|
||||
const char* url = argv[1];
|
||||
const char* infoPath = argv[2];
|
||||
const char* configPath = argv[3];
|
||||
int argi = 1;
|
||||
const char* url = argc == 4 ? argv[argi++] : NULL;
|
||||
const char* infoPath = argv[argi++];
|
||||
const char* configPath = argv[argi++];
|
||||
|
||||
// read the info
|
||||
BPackageKit::BRepositoryInfo repoInfo;
|
||||
DIE_ON_ERROR(repoInfo.SetTo(infoPath),
|
||||
"failed to read repository info file \"%s\"", infoPath);
|
||||
|
||||
if (url == NULL)
|
||||
url = repoInfo.OriginalBaseURL();
|
||||
|
||||
// init and write the config
|
||||
BPackageKit::BRepositoryConfig repoConfig;
|
||||
repoConfig.SetName(repoInfo.Name());
|
||||
|
Loading…
x
Reference in New Issue
Block a user