diff --git a/CMakeLists.txt b/CMakeLists.txt index 378fa81..f6613e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,14 @@ project(csol) set(CSOL_VERSION "0.1.0") -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) configure_file(src/config.h.in src/config.h) -configure_file(src/csolrc csolrc COPYONLY) +configure_file(csolrc csolrc COPYONLY) +file(COPY games DESTINATION .) +file(COPY themes DESTINATION .) find_package(Curses REQUIRED) include_directories("$(CURSES_INCLUDE_DIR)") diff --git a/src/csolrc b/csolrc similarity index 100% rename from src/csolrc rename to csolrc diff --git a/src/main.c b/src/main.c index c797c5e..5de8cfe 100644 --- a/src/main.c +++ b/src/main.c @@ -18,7 +18,7 @@ #include "ui.h" #include "util.h" -const char *short_options = "hvlt:Tms:"; +const char *short_options = "hvlt:Tms:c:"; const struct option long_options[] = { {"help", no_argument, NULL, 'h'}, @@ -28,6 +28,7 @@ const struct option long_options[] = { {"themes", no_argument, NULL, 'T'}, {"mono", no_argument, NULL, 'm'}, {"seed", required_argument, NULL, 's'}, + {"config", required_argument, NULL, 'c'}, {0, 0, 0, 0} }; @@ -97,6 +98,7 @@ int main(int argc, char *argv[]) { int colors = 1; unsigned int seed = time(NULL); enum action action = PLAY; + char *rc_file = NULL; char *game_name = NULL; char *theme_name = NULL; while ((opt = getopt_long(argc, argv, short_options, long_options, &option_index)) != -1) { @@ -111,6 +113,7 @@ int main(int argc, char *argv[]) { describe_option("T", "themes", "List available themes."); describe_option("m", "mono", "Disable colors."); describe_option("s ", "seed ", "Select seed."); + describe_option("c ", "config ", "Select configuration file."); return 0; case 'v': puts("csol " CSOL_VERSION); @@ -130,17 +133,24 @@ int main(int argc, char *argv[]) { case 's': seed = atol(optarg); break; + case 'c': + rc_file = optarg; + break; + } } if (optind < argc) { game_name = argv[optind]; } - char *rc_file = find_csolrc(); int error = 0; if (!rc_file) { - printf("csolrc: %s\n", strerror(errno)); - error = 1; - } else { + rc_file = find_csolrc(); + if (!rc_file) { + printf("csolrc: %s\n", strerror(errno)); + error = 1; + } + } + if (!error) { printf("Using configuration file: %s\n", rc_file); error = !execute_file(rc_file); }