po: Update German man pages translation
[dpkg.git] / lib / dpkg / options-parsers.c
blobde5bf69f8d7c9ba1e9b87902ea126938248061ee
1 /*
2 * libdpkg - Debian packaging suite library routines
3 * options-parsers.c - command-line options parser helpers
5 * Copyright © 2014 Guillem Jover <guillem@debian.org>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 #include <config.h>
22 #include <compat.h>
24 #include <dpkg/i18n.h>
25 #include <dpkg/dpkg-db.h>
26 #include <dpkg/error.h>
27 #include <dpkg/pkg-spec.h>
28 #include <dpkg/options.h>
30 /**
31 * Parse an argument as a package name.
33 * The string is parsed as a singleton package name, and a #pkginfo instance
34 * is returned.
36 * @param cmd The command information structure currently parsed.
37 * @param name The package name argument
39 * @return A package instance.
41 struct pkginfo *
42 dpkg_options_parse_pkgname(const struct cmdinfo *cmd, const char *name)
44 struct pkginfo *pkg;
45 struct dpkg_error err;
47 pkg = pkg_spec_parse_pkg(name, &err);
48 if (pkg == NULL)
49 badusage(_("--%s needs a valid package name but '%.250s' is not: %s"),
50 cmd->olong, name, err.str);
52 return pkg;