fix: rename to mfm and fix close
This commit is contained in:
parent
8def1979c1
commit
294231cfbb
3 changed files with 53 additions and 38 deletions
|
@ -1,8 +1,9 @@
|
|||
name: gx-vault
|
||||
---
|
||||
name: Minimalist FUSE Manager
|
||||
version: 0.1.0
|
||||
|
||||
targets:
|
||||
gx-vault:
|
||||
mfm:
|
||||
main: src/main.cr
|
||||
|
||||
# authors:
|
||||
|
@ -11,6 +12,10 @@ targets:
|
|||
# description: |
|
||||
# Short description of gx-vault
|
||||
|
||||
dependencies:
|
||||
shellwords:
|
||||
github: szTheory/shellwords-crystal
|
||||
|
||||
# dependencies:
|
||||
# pg:
|
||||
# github: will/crystal-pg
|
||||
|
|
21
src/cli.cr
21
src/cli.cr
|
@ -66,19 +66,26 @@ module GX
|
|||
|
||||
def run()
|
||||
@config.load_from_file
|
||||
# Correcting the fzf interaction part
|
||||
names_display = @config.vaults.map do |vault|
|
||||
vault.mounted? ? "#{vault.name} [#{ "open".colorize(:green) }]" : vault.name
|
||||
|
||||
names_display = {} of String => NamedTuple(vault: Vault, ansi_name: String)
|
||||
@config.vaults.each do |vault|
|
||||
result_name = vault.mounted? ? "#{vault.name} [open]" : vault.name
|
||||
ansi_name = vault.mounted? ? "#{vault.name} [#{ "open".colorize(:green) }]" : vault.name
|
||||
|
||||
names_display[result_name] = {
|
||||
vault: vault,
|
||||
ansi_name: ansi_name
|
||||
}
|
||||
end
|
||||
|
||||
selected_vault_name = Fzf.run(names_display.sort)
|
||||
puts ">> #{selected_vault_name}".colorize(:yellow)
|
||||
selected_vault = @config.vaults.find { |v| v.name == selected_vault_name }
|
||||
result_vault_name = Fzf.run(names_display.values.map(&.[:ansi_name]).sort)
|
||||
selected_vault = names_display[result_vault_name][:vault]
|
||||
puts ">> #{selected_vault.name}".colorize(:yellow)
|
||||
|
||||
if selected_vault
|
||||
selected_vault.mounted? ? selected_vault.unmount : selected_vault.mount
|
||||
else
|
||||
STDERR.puts "Vault not found.".colorize(:red)
|
||||
STDERR.puts "Vault not found: #{selected_vault}.".colorize(:red)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require "shellwords"
|
||||
|
||||
module GX
|
||||
class Vault
|
||||
getter name : String
|
||||
|
@ -30,8 +32,9 @@ class Vault
|
|||
puts "Vault #{name} is now available on #{mount_dir}".colorize(:green)
|
||||
end
|
||||
end
|
||||
|
||||
def unmount
|
||||
`fusermount -u #{mount_dir}`
|
||||
system("fusermount -u #{mount_dir.shellescape}")
|
||||
puts "Vault #{name} is now closed.".colorize(:green)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue