summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch/Client.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-12-16 03:15:51 +0000
committerMichi Henning <michi@zeroc.com>2004-12-16 03:15:51 +0000
commitb5c3efca572afd6c9cadbc87e9f4c068d312d928 (patch)
treee34f481e7ed94f176fcbe266767fea241dc3c764 /cpp/src/IcePatch/Client.cpp
parentremove now returns null if the key is not found (diff)
downloadice-b5c3efca572afd6c9cadbc87e9f4c068d312d928.tar.bz2
ice-b5c3efca572afd6c9cadbc87e9f4c068d312d928.tar.xz
ice-b5c3efca572afd6c9cadbc87e9f4c068d312d928.zip
Changed command line parsing to use IceUtil::Options.
Diffstat (limited to 'cpp/src/IcePatch/Client.cpp')
-rw-r--r--cpp/src/IcePatch/Client.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/cpp/src/IcePatch/Client.cpp b/cpp/src/IcePatch/Client.cpp
index ccbfcaf4bd2..207ac314fa8 100644
--- a/cpp/src/IcePatch/Client.cpp
+++ b/cpp/src/IcePatch/Client.cpp
@@ -7,6 +7,7 @@
//
// **********************************************************************
+#include <IceUtil/Options.h>
#include <Ice/Application.h>
#include <Ice/SliceChecksums.h>
#include <IcePatch/FileDescFactory.h>
@@ -62,6 +63,33 @@ IcePatch::Client::run(int argc, char* argv[])
{
Glacier::RouterPrx router;
+ IceUtil::Options opts;
+ opts.addOpt("h", "help");
+ opts.addOpt("v", "version");
+
+ vector<string> subdirs;
+ try
+ {
+ subdirs = opts.parse(argc, argv);
+ }
+ catch(const IceUtil::Options::BadOpt& e)
+ {
+ cerr << e.reason << endl;
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ if(opts.isSet("h") || opts.isSet("help"))
+ {
+ usage();
+ return EXIT_SUCCESS;
+ }
+ if(opts.isSet("v") || opts.isSet("version"))
+ {
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
+ }
+
try
{
int idx = 1;
@@ -89,15 +117,7 @@ IcePatch::Client::run(int argc, char* argv[])
}
}
- vector<string> subdirs;
- if(argc > 1)
- {
- for(int i = 1; i < argc; ++i)
- {
- subdirs.push_back(argv[i]);
- }
- }
- else
+ if(subdirs.empty())
{
subdirs.push_back(".");
}