diff --git a/src/commands/mapping_create.cr b/src/commands/mapping_create.cr index d2882d1..e03db95 100644 --- a/src/commands/mapping_create.cr +++ b/src/commands/mapping_create.cr @@ -4,12 +4,14 @@ # Copyright © 2024 Glenn Y. Rolland require "./abstract_command" +require "../models/filesystem_factory" module GX::Commands class MappingCreate < AbstractCommand def initialize(@config : GX::Config) @config.load_from_env @config.load_from_file + @config.save_to_file end def execute diff --git a/src/config.cr b/src/config.cr index cc7f43e..182c186 100644 --- a/src/config.cr +++ b/src/config.cr @@ -120,5 +120,15 @@ module GX end @root = root end + + def save_to_file + return if @path.nil? + if @path + File.write(@path.to_s, @root.to_yaml) + else + Log.error { "Configuration path is nil, cannot save configuration." } + end + Log.info { "Configuration saved to #{@path}" } + end end end