4 // Copyright (c) 2000-2005 Per Liden
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
23 #error This program requires GCC 3.x to compile.
38 static pkgutil
* select_utility(const string
& name
)
42 else if (name
== "pkgrm")
44 else if (name
== "pkginfo")
47 throw runtime_error("command not supported by pkgutils");
50 int main(int argc
, char** argv
)
52 string name
= basename(argv
[0]);
55 auto_ptr
<pkgutil
> util(select_utility(name
));
57 // Handle common options
58 for (int i
= 1; i
< argc
; i
++) {
59 string
option(argv
[i
]);
60 if (option
== "-v" || option
== "--version") {
61 util
->print_version();
63 } else if (option
== "-h" || option
== "--help") {
69 util
->run(argc
, argv
);
70 } catch (runtime_error
& e
) {
71 cerr
<< name
<< ": " << e
.what() << endl
;