feat: add configuration saving functionality to MappingCreate command

This commit is contained in:
Glenn Y. Rolland 2024-12-10 23:58:38 +01:00
parent 4acbaf7d83
commit 01804f1139
2 changed files with 12 additions and 0 deletions

View file

@ -4,12 +4,14 @@
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
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

View file

@ -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