Author: jreidinger
Date: Fri Mar 7 14:54:56 2008
New Revision: 9047
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9047&view=rev
Log:
addrepo accept one argument and it must be URI to .repo file (bcn #240018)
Modified:
trunk/zypper/doc/zypper.8
trunk/zypper/src/zypper.cc
Modified: trunk/zypper/doc/zypper.8
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=9047&r1=9046&r2=9047&view=diff
==============================================================================
--- trunk/zypper/doc/zypper.8 (original)
+++ trunk/zypper/doc/zypper.8 Fri Mar 7 14:54:56 2008
@@ -315,8 +315,8 @@
Management servers, as well as local files.
.TP
-.B addrepo (ar) [options] <URI> <alias>
-Add a new repository specified by URI and assign specified alias to it.
+.B addrepo (ar) [options] <URI> [<alias>]
+Add a new repository specified by URI and assign specified alias to it or specify URI to repo file.
.TP
\fI\-r, \-\-repo\fR
Read URI and alias from specified .repo file
Modified: trunk/zypper/src/zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=9047&r1=9046&r2=9047&view=diff
==============================================================================
--- trunk/zypper/src/zypper.cc (original)
+++ trunk/zypper/src/zypper.cc Fri Mar 7 14:54:56 2008
@@ -854,9 +854,9 @@
specific_options = service_add_options;
_command_help = boost::str(format(_(
// TranslatorExplanation the %s = "yast2, rpm-md, plaindir"
- "addrepo (ar) [options] <URI> <alias>\n"
+ "addrepo (ar) [options] <URI> [<alias>]\n"
"\n"
- "Add repository specified by URI to the system and assing the specified alias to it.\n"
+ "Add repository specified by URI to the system and assing the specified alias to it or specified by URI to repo file.\n"
"\n"
" Command options:\n"
"-r, --repo Read the URL and alias from a file (even remote)\n"
@@ -1494,34 +1494,37 @@
string type = copts.count("type") ? copts["type"].front() : "";
// display help message if insufficient info was given
- if (_arguments.size() < 2)
- {
- out().error(
- _("Too few arguments. At least URL and alias are required."));
- ERR << "Too few arguments. At least URL and alias are required." << endl;
+ switch (_arguments.size()){
+ case 0:
+ out().error(_("Too few arguments."));
+ ERR << "Too few arguments." << endl;
out().info(_command_help);
setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
return;
- }
-
- Url url = make_url (_arguments[0]);
- if (!url.isValid())
- {
- setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
- return;
- }
+ case 1:
+ add_repo_from_file(*this,_arguments[0], enabled, refresh);
+ break;
+ case 2:
+ Url url = make_url (_arguments[0]);
+ if (!url.isValid())
+ {
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
- // by default, enable the repo and set autorefresh to false
- if (indeterminate(enabled)) enabled = true;
- if (indeterminate(refresh)) refresh = false;
+ // by default, enable the repo and set autorefresh to false
+ if (indeterminate(enabled)) enabled = true;
+ if (indeterminate(refresh)) refresh = false;
- warn_if_zmd();
+ warn_if_zmd();
- // load gpg keys
- init_target(*this);
+ // load gpg keys
+ init_target(*this);
- add_repo_by_url(
- *this, url, _arguments[1]/*alias*/, type, enabled, refresh);
+ add_repo_by_url(
+ *this, url, _arguments[1]/*alias*/, type, enabled, refresh);
+ return;
+ }
}
catch (const repo::RepoUnknownTypeException & e)
{
@@ -1638,7 +1641,7 @@
if (match_repo(*this,_arguments[0], &repo)){
rename_repo(*this, repo.alias(), _arguments[1]);
} else {
- this->out().error(boost::str(format(
+ out().error(boost::str(format(
_("Repository '%s' not found.")) % _arguments[0]));
ERR << "Repo " << _arguments[0] << " not found" << endl;
}
@@ -1688,7 +1691,7 @@
if (match_repo(*this,_arguments[0],&repo)){
modify_repo(*this, repo.alias());
} else {
- this->out().error(
+ out().error(
boost::str(format(_("Repository %s not found.")) % _arguments[0]));
ERR << "Repo " << _arguments[0] << " not found" << endl;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org