summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/cmndline.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib/cmndline.cc')
-rw-r--r--apt-pkg/contrib/cmndline.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 9546eac8f..858a5300a 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cmndline.cc,v 1.5 1998/10/24 20:14:34 jgg Exp $
+// $Id: cmndline.cc,v 1.6 1998/11/25 23:54:22 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -302,7 +302,7 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
return true;
}
/*}}}*/
-// CommandLine::FileSize - Count the number of filenames /*{{{*/
+// CommandLine::FileSize - Count the number of filenames /*{{{*/
// ---------------------------------------------------------------------
/* */
unsigned int CommandLine::FileSize() const
@@ -313,3 +313,26 @@ unsigned int CommandLine::FileSize() const
return Count;
}
/*}}}*/
+// CommandLine::DispatchArg - Do something with the first arg /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool CommandLine::DispatchArg(Dispatch *Map)
+{
+ int I;
+ for (I = 0; Map[I].Match != 0; I++)
+ {
+ if (strcmp(FileList[0],Map[I].Match) == 0)
+ {
+ bool Res = Map[I].Handler(*this);
+ if (Res == false && _error->PendingError() == false)
+ _error->Error("Handler silently failed");
+ return Res;
+ }
+ }
+
+ // No matching name
+ if (Map[I].Match == 0)
+ _error->Error("Invalid operation %s",FileList[0]);
+ return false;
+}
+ /*}}}*/