4 // Copyright (c) 2000-2005 Per Liden
5 // Copyright (c) 2006-2010 by CRUX team (http://crux.nu)
7 // This program 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 program 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, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
24 #error This program requires GCC 3.x to compile.
39 static pkgutil
* select_utility(const string
& name
)
43 else if (name
== "pkgrm")
45 else if (name
== "pkginfo")
48 throw runtime_error("command not supported by pkgutils");
51 int main(int argc
, char** argv
)
53 string name
= basename(argv
[0]);
56 auto_ptr
<pkgutil
> util(select_utility(name
));
58 // Handle common options
59 for (int i
= 1; i
< argc
; i
++) {
60 string
option(argv
[i
]);
61 if (option
== "-v" || option
== "--version") {
62 util
->print_version();
64 } else if (option
== "-h" || option
== "--help") {
70 util
->run(argc
, argv
);
71 } catch (runtime_error
& e
) {
72 cerr
<< name
<< ": " << e
.what() << endl
;