From 1c184a55575d5f2e8576e3bbcdca7f738c088881 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 18 Nov 2023 23:31:04 +0100 Subject: [PATCH] fix: delay config file discovery --- src/config.cr | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/config.cr b/src/config.cr index f5f6ba0..7a71c9f 100644 --- a/src/config.cr +++ b/src/config.cr @@ -25,7 +25,7 @@ module GX getter home_dir : String property verbose : Bool property mode : Mode - property path : String + property path : String? property args : AddArgs.class | DelArgs.class | NoArgs.class def initialize() @@ -37,7 +37,7 @@ module GX @verbose = false @mode = Mode::Mount @filesystems = [] of Filesystem - @path = detect_config_file() + @path = nil @args = NoArgs end @@ -66,13 +66,18 @@ module GX end def load_from_file + path = @path + if path.nil? + path = detect_config_file() + end + @path = path @filesystems = [] of Filesystem - if !File.exists? @path - Log.error { "File #{@path} does not exist!".colorize(:red) } + if !File.exists? path + Log.error { "File #{path} does not exist!".colorize(:red) } exit(1) end - load_filesystems(@path) + load_filesystems(path) end private def load_filesystems(config_path : String) -- 2.43.4