summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2006-04-30 11:01:53 +0000
committerschodet2006-04-30 11:01:53 +0000
commitbd9ac003fcfeb39c172e2a59b103748f56fbffcc (patch)
tree05689c26a60eb0f7ed4911bc8e18d14e1280a988
parentf2ef1237d4f850edf4ba67c97c2ab2b46ddbd229 (diff)
Ajout de l'option -F pour choisir le fichier de config.
-rw-r--r--i/marvin/src/config/config_data.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/i/marvin/src/config/config_data.cc b/i/marvin/src/config/config_data.cc
index b126082..e531031 100644
--- a/i/marvin/src/config/config_data.cc
+++ b/i/marvin/src/config/config_data.cc
@@ -94,7 +94,37 @@ class ConfigParser : public Parser
void
ConfigData::init (int &argc, char **&argv, const std::string &file)
{
+ std::string configFile (file);
+ // Parse la ligne de commande.
+ for (int i = 1; i < argc; )
+ {
+ int del = 0;
+ // -F CONFIG_FILE
+ if (argv[i][0] == '-' && argv[i][1] == 'F')
+ {
+ if (argv[i][2] != '\0')
+ {
+ del = 1;
+ configFile = &argv[i][2];
+ }
+ else if (i + 1 < argc)
+ {
+ del = 2;
+ configFile = argv[i + 1];
+ }
+ }
+ // Supprime ces arguments de la liste.
+ if (del)
+ {
+ for (int j = i; j < argc - del + 1; j++)
+ argv[j] = argv[j + del];
+ argc -= del;
+ }
+ else
+ i++;
+ }
+ // Lit le fichier de config.
ConfigParser p (*this);
- p.parseFile (file);
+ p.parseFile (configFile);
}