summaryrefslogtreecommitdiff
path: root/src/argparser.h
blob: 1859c3573615dcc382fe6dcabd23d1a77ce29f0d (plain)
    1 ////////////////////////////////////////////////////////////////////////
    2 // FILE:        argparser.h
    3 // AUTHOR:      Johannes Winkelmann, jw@tks6.net
    4 // COPYRIGHT:   (c) 2002 by Johannes Winkelmann
    5 // ---------------------------------------------------------------------
    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.
   10 ////////////////////////////////////////////////////////////////////////
   11 
   12 #ifndef _ARGPARSER_H_
   13 #define _ARGPARSER_H_
   14 
   15 #include <list>
   16 #include <string>
   17 using namespace std;
   18 
   19 /*!
   20   \class ArgParser
   21   \brief Argument Parser
   22 
   23   This is the argument parser for prt-get.
   24 */
   25 class ArgParser
   26 {
   27 public:
   28     ArgParser( int argc, char** argv );
   29 
   30     bool parse();
   31 
   32     /*! Command type */
   33     enum Type { HELP, LIST, SEARCH, DSEARCH, INSTALL, DEPINST,
   34                 INFO, DEPENDS, ISINST, DUP, UPDATE,
   35                 QUICKDEP, DIFF, GRPINST, GRPUPDATE,
   36                 QUICKDIFF, SHOW_VERSION, CREATE_CACHE, PATH,
   37                 LISTINST, PRINTF, README, DEPENDENT, SYSUP,
   38                 CURRENT, FSEARCH, LOCK, UNLOCK, LISTLOCKED,
   39                 CAT, LS, EDIT, REMOVE,
   40                 DEPTREE, DUMPCONFIG };
   41 
   42     bool isCommandGiven() const;
   43     bool isForced() const;
   44     bool isTest() const;
   45     bool isAlternateConfigGiven() const;
   46     bool useCache() const;
   47     bool wasCalledAsPrtCached() const;
   48     bool writeLog() const;
   49     bool hasFilter() const;
   50     bool noStdConfig() const;
   51     bool nodeps() const;
   52     bool all() const;
   53     bool printPath() const;
   54     bool execPreInstall() const;
   55     bool execPostInstall() const;
   56     bool preferHigher() const;
   57     bool strictDiff() const;
   58     bool useRegex() const;
   59     bool fullPath() const;
   60 
   61     const string& alternateConfigFile() const;
   62     const string& pkgmkArgs() const;
   63     const string& pkgaddArgs() const;
   64     const string& pkgrmArgs() const;
   65     const string& sortArgs() const;
   66     const string& filter() const;
   67     const string& installRoot() const;
   68     const string& ignore() const;
   69 
   70 
   71     Type commandType() const;
   72 
   73     const string& commandName() const;
   74     const string& unknownOption() const;
   75 
   76     const list<char*>& otherArgs() const;
   77 
   78     int verbose() const;
   79 
   80     enum ConfigArgType { CONFIG_SET, CONFIG_APPEND, CONFIG_PREPEND };
   81 
   82     const list< pair<char*, ConfigArgType> > configData() const;
   83 
   84 
   85 private:
   86 
   87     bool m_isCommandGiven;
   88     bool m_isForced;
   89     bool m_isTest;
   90     bool m_isAlternateConfigGiven;
   91     bool m_useCache;
   92     bool m_calledAsPrtCache;
   93     bool m_hasFilter;
   94     bool m_noStdConfig;
   95 
   96     bool m_writeLog;
   97 
   98     bool m_nodeps;
   99 
  100     bool m_all;
  101     bool m_printPath;
  102 
  103     bool m_execPreInstall;
  104     bool m_execPostInstall;
  105     bool m_preferHigher;
  106     bool m_strictDiff;
  107     bool m_useRegex;
  108     bool m_fullPath;
  109 
  110     string m_alternateConfigFile;
  111     string m_pkgmkArgs;
  112     string m_pkgaddArgs;
  113     string m_pkgrmArgs;
  114     string m_sortArgs;
  115     string m_filter;
  116     string m_commandName;
  117     string m_unknownOption;
  118     string m_installRoot;
  119     string m_ignore;
  120 
  121     Type m_commandType;
  122 
  123     int m_argc;
  124     char** m_argv;
  125 
  126     int m_verbose;
  127 
  128     list<char*> m_otherArgs;
  129 
  130     list< pair<char*, ConfigArgType> > m_configData;
  131 };
  132 
  133 #endif /* _ARGPARSER_H_ */

Generated by cgit