1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/monitor/ArgumentParser.cpp
13 #include "monitor/ArgumentParser.h"
14 #include "config/Parser.h"
15 #include "util/MessageSystem.h"
19 int ArgumentParser::parse(Config::Vault
*vault
, char **argv
) {
21 for(arg
= 1; argv
[arg
] != NULL
; arg
++) {
22 if(std::strcmp(argv
[arg
], "--") == 0) {
26 else if(std::strcmp(argv
[arg
], "--set") == 0) {
27 if(argv
[++arg
] == NULL
) {
28 Message(Warning
, "Expected argument to --set.");
31 /*std::cout << argv[arg+1] << std::endl;*/
32 std::string line
= argv
[arg
];
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
);
40 else if(std::strcmp(argv
[arg
], "--use-module") == 0) {
41 if(argv
[++arg
] == NULL
) {
42 Message(Warning
, "Expected argument to --use-module.");
45 vault
->set("::modules", argv
[arg
]);
46 /*std::cout << "ArgumentParser: Using module " << argv[++arg] << std::endl;*/
48 else if(std::strcmp(argv
[arg
], "--search") == 0) {
49 Config::Parser().parseDirectory(vault
, argv
[++arg
]);
51 else if(std::strcmp(argv
[arg
], "--help") == 0 ||
52 std::strcmp(argv
[arg
], "--usage") == 0) {
53 vault
->set("::help", "true");
55 else if(std::strcmp(argv
[arg
], "--version") == 0) {
56 vault
->set("::version", "true");
58 else if(std::strcmp(argv
[arg
], "--list-attributes") == 0) {
59 vault
->set("::list-attributes", "true");
61 else if(std::strcmp(argv
[arg
], "--output") == 0) {
62 if(argv
[++arg
] == NULL
) {
63 Message(Warning
, "Expected argument to --output.");
66 vault
->set("::output", argv
[arg
]);
68 else if(std::strncmp(argv
[arg
], "--", 2) == 0) {
69 Message(Warning
, "Unknown argument \"" << argv
[arg
] << "\".");
77 } // namespace Monitor