diff options
Diffstat (limited to 'src/libmain/shared.hh')
-rw-r--r-- | src/libmain/shared.hh | 35 |
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; - } |