2 Aesalon, a tool to visualize a program's behaviour at run-time.
3 Copyright (C) 2010, Aesalon Development Team.
5 Aesalon is distributed under the terms of the GNU GPLv3. For more
6 licensing information, see the file LICENSE included with the distribution.
8 @file monitor/src/config/ArgumentParser.cpp
15 #include "config/ArgumentParser.h"
16 #include "config/Parser.h"
17 #include "config/ConcreteVault.h"
18 #include "common/PathSanitizer.h"
23 int ArgumentParser::parse(ConcreteVault
*vault
, char **argv
) {
25 for(arg
= 1; argv
[arg
] != NULL
; arg
++) {
26 if(std::strcmp(argv
[arg
], "--") == 0) {
30 else if(std::strcmp(argv
[arg
], "--set") == 0) {
31 /*std::cout << argv[arg+1] << std::endl;*/
32 std::string line
= argv
[arg
+1];
33 std::string::size_type divider
= line
.find('=');
34 std::string key
= line
.substr(0, divider
);
35 std::string data
= line
.substr(divider
+1);
38 vault
->set(key
, data
);
42 else if(std::strcmp(argv
[arg
], "--use-module") == 0) {
43 vault
->set("::modules", argv
[++arg
]);
44 /*std::cout << "ArgumentParser: Using module " << argv[++arg] << std::endl;*/
46 else if(std::strcmp(argv
[arg
], "--search") == 0) {
47 Parser().parseDirectory(vault
, argv
[++arg
]);
49 else if(std::strcmp(argv
[arg
], "--help") == 0) {
50 vault
->set("::help", "true");
52 else if(std::strcmp(argv
[arg
], "--version") == 0) {
53 vault
->set("::version", "true");
55 else if(std::strcmp(argv
[arg
], "--list-attributes") == 0) {
56 vault
->set("::list-attributes", "true");
58 else if(std::strncmp(argv
[arg
], "--", 2) == 0) {
59 std::cout
<< "Unknown argument \"" << argv
[arg
] << "\".\n";
60 // TODO: do something about the error.
69 } // namespace Monitor