1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 06:11:46 +02:00

* Debug levels. Use `--verbose / -v LEVEL' to display only messages

up to the given verbosity levels.  These currently are:

    lvlError = 0, 
    lvlNormal = 5,
    lvlDebug = 10,
    lvlDebugMore = 15

  although only lvlError and lvlDebug are actually used right now.
This commit is contained in:
Eelco Dolstra 2003-07-24 08:53:43 +00:00
parent b75719b984
commit 1a7468a57a
8 changed files with 68 additions and 25 deletions

View file

@ -1,4 +1,5 @@
#include <iostream>
#include <cctype>
extern "C" {
#include <aterm2.h>
@ -32,7 +33,12 @@ static void initAndRun(int argc, char * * argv)
string arg = *it;
if (arg.length() > 2 && arg[0] == '-' && arg[1] != '-') {
for (unsigned int i = 1; i < arg.length(); i++)
args.insert(it, (string) "-" + arg[i]);
if (isalpha(arg[i]))
args.insert(it, (string) "-" + arg[i]);
else {
args.insert(it, string(arg, i));
break;
}
it = args.erase(it);
} else it++;
}
@ -50,18 +56,21 @@ int main(int argc, char * * argv)
try {
initAndRun(argc, argv);
} catch (UsageError & e) {
cerr << format(
"error: %1%\n"
"Try `%2% --help' for more information.\n")
% e.what() % programId;
msg(lvlError,
format(
"error: %1%\n"
"Try `%2% --help' for more information.")
% e.what() % programId);
return 1;
} catch (Error & e) {
cerr << format("error: %1%\n") % e.msg();
msg(lvlError, format("error: %1%") % e.msg());
return 1;
} catch (exception & e) {
cerr << format("error: %1%\n") % e.what();
msg(lvlError, format("error: %1%") % e.what());
return 1;
}
return 0;
}