Fail if config can't be read.
the build was successful Details

This commit is contained in:
tastytea 2018-12-31 14:00:39 +01:00
parent c0793664f9
commit cc974b5cbb
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.2) cmake_minimum_required (VERSION 3.2)
project(compilescript project(compilescript
VERSION 0.3.0 VERSION 0.3.1
LANGUAGES CXX LANGUAGES CXX
) )

View File

@ -46,13 +46,13 @@ string compiler = "g++";
fs::path cache_dir; fs::path cache_dir;
int clean_after_hours = 30 * 24; int clean_after_hours = 30 * 24;
void read_settings() bool read_settings()
{ {
bool need_save = false; bool need_save = false;
xdgcfg config("compilescript.cfg"); xdgcfg config("compilescript.cfg");
if (config.read() != 0) if (config.read() != 0)
{ {
config.write(); return false;
} }
libconfig::Setting &cfg = config.get_cfg().getRoot(); libconfig::Setting &cfg = config.get_cfg().getRoot();
@ -98,6 +98,8 @@ void read_settings()
{ {
config.write(); config.write();
} }
return true;
} }
void cleanup() void cleanup()
@ -128,7 +130,10 @@ void cleanup()
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
read_settings(); if (!read_settings())
{
return 1;
}
if (argc <= 1) if (argc <= 1)
{ {