summaryrefslogtreecommitdiff
path: root/src/argparser.h
blob: b5604483a84cfad6e2a819dd5367d7382969f339 (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, LISTORPHANS };
   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     bool recursive() const;
   61     bool printTree() const;
   62 
   63     const string& alternateConfigFile() const;
   64     const string& pkgmkArgs() const;
   65     const string& pkgaddArgs() const;
   66     const string& pkgrmArgs() const;
   67     const string& sortArgs() const;
   68     const string& filter() const;
   69     const string& installRoot() const;
   70     const string& ignore() const;
   71 
   72 
   73     Type commandType() const;
   74 
   75     const string& commandName() const;
   76     const string& unknownOption() const;
   77 
   78     const list<char*>& otherArgs() const;
   79 
   80     int verbose() const;
   81 
   82     enum ConfigArgType { CONFIG_SET, CONFIG_APPEND, CONFIG_PREPEND };
   83 
   84     const list< pair<char*, ConfigArgType> > configData() const;
   85 
   86 
   87 private:
   88 
   89     bool m_isCommandGiven;
   90     bool m_isForced;
   91     bool m_isTest;
   92     bool m_isAlternateConfigGiven;
   93     bool m_useCache;
   94     bool m_calledAsPrtCache;
   95     bool m_hasFilter;
   96     bool m_noStdConfig;
   97 
   98     bool m_writeLog;
   99 
  100     bool m_nodeps;
  101 
  102     bool m_all;
  103     bool m_printPath;
  104 
  105     bool m_execPreInstall;
  106     bool m_execPostInstall;
  107     bool m_preferHigher;
  108     bool m_strictDiff;
  109     bool m_useRegex;
  110     bool m_fullPath;
  111 
  112     bool m_recursive;
  113     bool m_printTree;
  114 
  115     string m_alternateConfigFile;
  116     string m_pkgmkArgs;
  117     string m_pkgaddArgs;
  118     string m_pkgrmArgs;
  119     string m_sortArgs;
  120     string m_filter;
  121     string m_commandName;
  122     string m_unknownOption;
  123     string m_installRoot;
  124     string m_ignore;
  125 
  126     Type m_commandType;
  127 
  128     int m_argc;
  129     char** m_argv;
  130 
  131     int m_verbose;
  132 
  133     list<char*> m_otherArgs;
  134 
  135     list< pair<char*, ConfigArgType> > m_configData;
  136 };
  137 
  138 #endif /* _ARGPARSER_H_ */

Generated by cgit