mfm/src/models/global_config.cr
Glenn 23d4def217
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
feat: implement local & global mount_point definition
2023-11-24 00:20:16 +01:00

28 lines
698 B
Crystal

# SPDX-License-Identifier: GPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
require "yaml"
require "./abstract_filesystem_config"
module GX::Models
class GlobalConfig
include YAML::Serializable
include YAML::Serializable::Strict
@[YAML::Field(key: "mount_point")]
getter mount_point : String?
def after_initialize()
home_dir = ENV["HOME"] || raise "Home directory not found"
# Set default mountpoint from global if none defined
if @mount_point.nil? || @mount_point.try &.empty?
@mount_point = File.join(home_dir, "mnt")
end
end
end
end