parent
8a62c93a6c
commit
4cbca297b3
|
@ -69,7 +69,7 @@ An example configuration file can look as follows:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also run the program with `gitea-irc-bot myConfig.json` to specify a custom JSON configuration path other than the default.
|
You can run the program with `GIB_CONFIG=myConfig.json gitea-irc-bot` to specify a custom JSON configuration path other than the default.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
20
source/app.d
20
source/app.d
|
@ -251,29 +251,27 @@ void notifySH(string message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(string[] args)
|
void main()
|
||||||
{
|
{
|
||||||
string configFilePath;
|
string configFilePath;
|
||||||
|
|
||||||
/* If given an argument then use it as the configuration file */
|
import std.process : environment;
|
||||||
if(args.length == 2)
|
|
||||||
|
/* If given an environment variable then use it as the configuration file */
|
||||||
|
if(environment.get("GIB_CONFIG") !is null)
|
||||||
{
|
{
|
||||||
/* Configuration file path */
|
/* Configuration file path */
|
||||||
configFilePath = args[1];
|
configFilePath = environment.get("GIB_CONFIG");
|
||||||
}
|
}
|
||||||
/* If we have more than two arguments then it is an error */
|
/* If there is no environment variable, assume default config.json file */
|
||||||
else if(args.length > 2)
|
|
||||||
{
|
|
||||||
logger.error("Only one argument, the path to the configuration file, is allowed");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
/* If there are no arguments, assume default config.json file */
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Set to the default config path */
|
/* Set to the default config path */
|
||||||
configFilePath = "config.json";
|
configFilePath = "config.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File configFile;
|
File configFile;
|
||||||
|
|
Loading…
Reference in New Issue