about summary refs log tree commit diff
path: root/src/libmain/shared.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-13T01·50+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-13T01·50+0200
commit47e185847e729d49e6aa376e8299fd66ef834a0a (patch)
tree6abfc9e9d5744e78b123c73182c30253c9a39681 /src/libmain/shared.hh
parent5bed74d1b0acd8d8083fb82a31d907ad2348a91b (diff)
Refactor option handling
Diffstat (limited to 'src/libmain/shared.hh')
-rw-r--r--src/libmain/shared.hh35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh
index b29b08bb597e..c74e7cbc197d 100644
--- a/src/libmain/shared.hh
+++ b/src/libmain/shared.hh
@@ -7,25 +7,28 @@
 #include <locale>
 
 
-/* These are not implemented here, but must be implemented by a
-   program linking against libmain. */
+namespace nix {
 
-/* Main program.  Called by main() after the ATerm library has been
-   initialised and some default arguments have been processed (and
-   removed from `args').  main() will catch all exceptions. */
-void run(nix::Strings args);
+MakeError(UsageError, nix::Error);
 
-/* Should print a help message to stdout and return. */
-void printHelp();
+class Exit : public std::exception
+{
+public:
+    int status;
+    Exit() : status(0) { }
+    Exit(int status) : status(status) { }
+};
 
-extern std::string programId;
+class StoreAPI;
 
+int handleExceptions(const string & programName, std::function<void()> fun);
 
-namespace nix {
+void initNix();
 
-MakeError(UsageError, nix::Error);
+void parseCmdLine(int argc, char * * argv,
+    std::function<bool(Strings::iterator & arg, const Strings::iterator & end)> parseArg);
 
-class StoreAPI;
+void printVersion(const string & programName);
 
 /* Ugh.  No better place to put this. */
 void printGCWarning();
@@ -36,6 +39,9 @@ void printMissing(const PathSet & willBuild,
     const PathSet & willSubstitute, const PathSet & unknown,
     unsigned long long downloadSize, unsigned long long narSize);
 
+string getArg(const string & opt,
+    Strings::iterator & i, const Strings::iterator & end);
+
 template<class N> N getIntArg(const string & opt,
     Strings::iterator & i, const Strings::iterator & end, bool allowUnit)
 {
@@ -65,9 +71,4 @@ void showManPage(const string & name);
 
 extern volatile ::sig_atomic_t blockInt;
 
-/* Exit code of the program. */
-extern int exitCode;
-
-extern char * * argvSaved;
-
 }