Compare commits

...

3 commits

Author SHA1 Message Date
32fea233d1 fix: rename global.mount_point to avoid misunderstanding
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-24 10:49:55 +01:00
84230a6828 feat: sort by fs.name instead of fs.type 2023-11-24 10:49:32 +01:00
211419ea02 chore: add watch+rebuild target 2023-11-24 10:48:55 +01:00
4 changed files with 15 additions and 9 deletions

View file

@ -6,4 +6,8 @@
all: build all: build
build: build:
shards build shards build --error-trace
@echo SUCCESS
watch:
watchexec --restart --delay-run 3 -c -e cr make build

View file

@ -173,7 +173,9 @@ module GX
} }
end end
result_filesystem_name = Fzf.run(names_display.values.map(&.[:ansi_name]).sort).strip ## FIXME: feat: allow to sort by name or by filesystem
sorted_values = names_display.values.sort_by { |item| item[:filesystem].name }
result_filesystem_name = Fzf.run(sorted_values.map(&.[:ansi_name])).strip
selected_filesystem = names_display[result_filesystem_name][:filesystem] selected_filesystem = names_display[result_filesystem_name][:filesystem]
puts ">> #{selected_filesystem.name}".colorize(:yellow) puts ">> #{selected_filesystem.name}".colorize(:yellow)

View file

@ -90,13 +90,13 @@ module GX
root = Models::RootConfig.from_yaml(file_patched) root = Models::RootConfig.from_yaml(file_patched)
global_mount_point = root.global.mount_point mount_point_base_safe = root.global.mount_point_base
raise Models::InvalidMountpointError.new("Invalid global mount point") if global_mount_point.nil? raise Models::InvalidMountpointError.new("Invalid global mount point") if mount_point_base_safe.nil?
root.filesystems.each do |selected_filesystem| root.filesystems.each do |selected_filesystem|
if !selected_filesystem.mount_point? if !selected_filesystem.mount_point?
selected_filesystem.mount_point = selected_filesystem.mount_point =
File.join(global_mount_point, selected_filesystem.mounted_name) File.join(mount_point_base_safe, selected_filesystem.mounted_name)
end end
end end
@root = root @root = root

View file

@ -14,16 +14,16 @@ module GX::Models
include YAML::Serializable include YAML::Serializable
include YAML::Serializable::Strict include YAML::Serializable::Strict
@[YAML::Field(key: "mount_point")] @[YAML::Field(key: "mount_point_base")]
getter mount_point : String? getter mount_point_base : String?
def after_initialize() def after_initialize()
raise InvalidEnvironmentError.new("Home directory not found") if !ENV["HOME"]? raise InvalidEnvironmentError.new("Home directory not found") if !ENV["HOME"]?
home_dir = ENV["HOME"] home_dir = ENV["HOME"]
# Set default mountpoint from global if none defined # Set default mountpoint from global if none defined
if @mount_point.nil? || @mount_point.try &.empty? if @mount_point_base.nil? || @mount_point_base.try &.empty?
@mount_point = File.join(home_dir, "mnt") @mount_point_base = File.join(home_dir, "mnt")
end end
end end
end end