]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/cmndline.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: cmndline.h,v 1.6 1999/01/18 06:20:07 jgg Exp $
4 /* ######################################################################
6 Command Line Class - Sophisticated command line parser
8 This class provides a unified command line parser/option handliner/
9 configuration mechanism. It allows the caller to specify the option
10 set and map the option set into the configuration class or other
13 Filenames are stripped from the option stream and put into their
16 The argument descriptor array can be initialized as:
18 CommandLine::Args Args[] =
19 {{'q',"quiet","apt::get::quiet",CommandLine::IntLevel},
23 HasArg - Means the argument has a value
24 IntLevel - Means the argument is an integer level indication, the
25 following -qqqq (+3) -q5 (=5) -q=5 (=5) are valid
26 Boolean - Means it is true/false or yes/no.
27 -d (true) --no-d (false) --yes-d (true)
28 --long (true) --no-long (false) --yes-long (true)
29 -d=yes (true) -d=no (false) Words like enable, disable,
30 true false, yes no and on off are recognized in logical
32 InvBoolean - Same as boolean but the case with no specified sense
33 (first case) is set to false.
34 ConfigFile - Means this flag should be interprited as the name of
35 a config file to read in at this point in option processing.
37 The default, if the flags are 0 is to use Boolean
39 ##################################################################### */
41 #ifndef PKGLIB_CMNDLINE_H
42 #define PKGLIB_CMNDLINE_H
45 #pragma interface "apt-pkg/cmndline.h"
48 #include <apt-pkg/configuration.h>
60 bool HandleOpt(int &I
,int argc
,const char *argv
[],
61 const char *&Opt
,Args
*A
,bool PreceedeMatch
= false);
70 InvBoolean
= (1 << 3),
71 ConfigFile
= (1 << 4) | HasArg
,
72 ArbItem
= (1 << 5) | HasArg
75 const char **FileList
;
77 bool Parse(int argc
,const char **argv
);
79 unsigned int FileSize() const;
80 bool DispatchArg(Dispatch
*List
,bool NoMatch
= true);
82 CommandLine(Args
*AList
,Configuration
*Conf
);
86 struct CommandLine::Args
93 inline bool end() {return ShortOpt
== 0 && LongOpt
== 0;};
94 inline bool IsBoolean() {return Flags
== 0 || (Flags
& (Boolean
|InvBoolean
)) != 0;};
97 struct CommandLine::Dispatch
100 bool (*Handler
)(CommandLine
&);