Compare commits
No commits in common. "be8980b74caf86078a21e06b28c1d8014dd55869" and "aec45eebd44d5b63cdcaec1eb79e9476a3210c01" have entirely different histories.
be8980b74c
...
aec45eebd4
11 changed files with 24 additions and 47 deletions
|
@ -6,9 +6,6 @@ module GX::Commands
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
puts "FIXME: detect if config is present"
|
|
||||||
puts "FIXME: compute config path (either default, or from command line)"
|
|
||||||
puts "FIXME: create config file from default if needed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
|
|
|
@ -6,12 +6,10 @@ module GX::Commands
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
puts "FIXME: detect option (either zsh or bash)"
|
|
||||||
puts "FIXME: output the right file from embedded data"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
GX::Types::Mode::GlobalCompletion
|
GX::Types::Mode::GlobalConfig
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,9 +89,7 @@ module GX
|
||||||
end
|
end
|
||||||
|
|
||||||
def choose_filesystem
|
def choose_filesystem
|
||||||
names_display = {} of String => NamedTuple(
|
names_display = {} of String => NamedTuple(filesystem: Models::AbstractFilesystemConfig, ansi_name: String)
|
||||||
filesystem: Models::AbstractFilesystemConfig,
|
|
||||||
ansi_name: String)
|
|
||||||
|
|
||||||
config_root = @config.root
|
config_root = @config.root
|
||||||
return if config_root.nil?
|
return if config_root.nil?
|
||||||
|
@ -116,7 +114,7 @@ module GX
|
||||||
end
|
end
|
||||||
|
|
||||||
# # FIXME: feat: allow to sort by name or by filesystem
|
# # FIXME: feat: allow to sort by name or by filesystem
|
||||||
sorted_values = names_display.values.sort_by!(&.[:filesystem].name)
|
sorted_values = names_display.values.sort_by { |item| item[:filesystem].name }
|
||||||
result_filesystem_name = Utils::Fzf.run(sorted_values.map(&.[:ansi_name])).strip
|
result_filesystem_name = Utils::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)
|
||||||
|
@ -125,7 +123,7 @@ module GX
|
||||||
STDERR.puts "Mapping not found: #{selected_filesystem}.".colorize(:red)
|
STDERR.puts "Mapping not found: #{selected_filesystem}.".colorize(:red)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
selected_filesystem
|
return selected_filesystem
|
||||||
end
|
end
|
||||||
|
|
||||||
private def generate_display_name(filesystem : Models::AbstractFilesystemConfig) : String
|
private def generate_display_name(filesystem : Models::AbstractFilesystemConfig) : String
|
||||||
|
@ -138,7 +136,7 @@ module GX
|
||||||
if ENV["DISPLAY"]? || ENV["WAYLAND_DISPLAY"]?
|
if ENV["DISPLAY"]? || ENV["WAYLAND_DISPLAY"]?
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ module GX::Models::Concerns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def _mount_wrapper(&) : Nil
|
def _mount_wrapper(&block) : Nil
|
||||||
mount_point_safe = mount_point
|
mount_point_safe = mount_point
|
||||||
return if mount_point_safe.nil?
|
return if mount_point_safe.nil?
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ module GX::Models
|
||||||
output: STDOUT,
|
output: STDOUT,
|
||||||
error: STDERR
|
error: STDERR
|
||||||
)
|
)
|
||||||
process.wait
|
return process.wait
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ module GX::Models
|
||||||
output: STDOUT,
|
output: STDOUT,
|
||||||
error: STDERR
|
error: STDERR
|
||||||
)
|
)
|
||||||
process.wait
|
return process.wait
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,7 @@ module GX::Models
|
||||||
output: STDOUT,
|
output: STDOUT,
|
||||||
error: STDERR
|
error: STDERR
|
||||||
)
|
)
|
||||||
process.wait
|
return process.wait
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,11 +12,11 @@ module GX::Parsers
|
||||||
)
|
)
|
||||||
parser.separator("\nCompletion commands:")
|
parser.separator("\nCompletion commands:")
|
||||||
|
|
||||||
parser.on("--bash", "Generate bash completion") do |_|
|
parser.on("--bash", "Generate bash completion") do |flag|
|
||||||
Log.info { "Set bash completion" }
|
Log.info { "Set bash completion" }
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("--zsh", "Generate zsh completion") do |_|
|
parser.on("--zsh", "Generate zsh completion") do |flag|
|
||||||
Log.info { "Set zsh completion" }
|
Log.info { "Set zsh completion" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,35 +30,19 @@ module GX::Parsers
|
||||||
parser.on("-t", "--type TYPE", "Set filesystem type") do |type|
|
parser.on("-t", "--type TYPE", "Set filesystem type") do |type|
|
||||||
add_args = add_args.merge({type: type})
|
add_args = add_args.merge({type: type})
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("-n", "--name", "Set mapping name") do |name|
|
parser.on("-n", "--name", "Set mapping name") do |name|
|
||||||
add_args = add_args.merge({name: name})
|
add_args = add_args.merge({name: name})
|
||||||
end
|
end
|
||||||
parser.on("--remote-user USER", "Set SSH user") do |user|
|
|
||||||
add_args = add_args.merge({remote_user: user})
|
|
||||||
end
|
|
||||||
parser.on("--remote-host HOST", "Set SSH host") do |host|
|
|
||||||
add_args = add_args.merge({remote_host: host})
|
|
||||||
end
|
|
||||||
parser.on("--source-path PATH", "Set remote path") do |path|
|
|
||||||
add_args = add_args.merge({remote_path: path})
|
|
||||||
end
|
|
||||||
|
|
||||||
|
parser.on("-p", "--path", "Set mapping encrypted path") do |path|
|
||||||
|
add_args = add_args.merge({path: path})
|
||||||
|
end
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "create"))
|
parser.separator(Utils.help_line(breadcrumbs + "create"))
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("edit", "Edit configuration") do |_|
|
parser.on("edit", "Edit configuration") do |_|
|
||||||
config.mode = Types::Mode::MappingEdit
|
config.mode = Types::Mode::MappingEdit
|
||||||
|
|
||||||
parser.on("--remote-user USER", "Set SSH user") do |user|
|
|
||||||
add_args = add_args.merge({remote_user: user})
|
|
||||||
end
|
|
||||||
parser.on("--remote-host HOST", "Set SSH host") do |host|
|
|
||||||
add_args = add_args.merge({remote_host: host})
|
|
||||||
end
|
|
||||||
parser.on("--source-path PATH", "Set remote path") do |path|
|
|
||||||
add_args = add_args.merge({remote_path: path})
|
|
||||||
end
|
|
||||||
|
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "edit"))
|
parser.separator(Utils.help_line(breadcrumbs + "edit"))
|
||||||
# abort("FIXME: Not implemented")
|
# abort("FIXME: Not implemented")
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,24 +21,24 @@ module GX::Parsers
|
||||||
config.path = path
|
config.path = path
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("-v", "--verbose", "Set more verbosity") do |_|
|
parser.on("-v", "--verbose", "Set more verbosity") do |flag|
|
||||||
Log.info { "Verbosity enabled" }
|
Log.info { "Verbosity enabled" }
|
||||||
config.verbose = true
|
config.verbose = true
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("-o", "--open", "Automatically open directory after mount") do |_|
|
parser.on("-o", "--open", "Automatically open directory after mount") do |flag|
|
||||||
Log.info { "Auto-open enabled" }
|
Log.info { "Auto-open enabled" }
|
||||||
config.auto_open = true
|
config.auto_open = true
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("--version", "Show version") do |_|
|
parser.on("--version", "Show version") do |flag|
|
||||||
config.mode = Types::Mode::GlobalVersion
|
config.mode = Types::Mode::GlobalVersion
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("-h", "--help", "Show this help") do |_|
|
parser.on("-h", "--help", "Show this help") do |flag|
|
||||||
config.mode = Types::Mode::GlobalHelp
|
config.mode = Types::Mode::GlobalHelp
|
||||||
config.help_options = Parsers::Options::HelpOptions.new
|
config.help_options = Parsers::Options::HelpOptions.new
|
||||||
config.help_options.try(&.parser_snapshot=(parser.dup))
|
config.help_options.try { |opts| opts.parser_snapshot = parser.dup }
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.separator("\nGlobal commands:")
|
parser.separator("\nGlobal commands:")
|
||||||
|
@ -46,7 +46,7 @@ module GX::Parsers
|
||||||
parser.on("config", "Manage configuration file") do
|
parser.on("config", "Manage configuration file") do
|
||||||
config.mode = Types::Mode::GlobalHelp
|
config.mode = Types::Mode::GlobalHelp
|
||||||
config.help_options = Parsers::Options::HelpOptions.new
|
config.help_options = Parsers::Options::HelpOptions.new
|
||||||
config.help_options.try(&.parser_snapshot=(parser.dup))
|
config.help_options.try { |opts| opts.parser_snapshot = parser.dup }
|
||||||
|
|
||||||
# config.command = Commands::Config.new(config)
|
# config.command = Commands::Config.new(config)
|
||||||
Parsers::ConfigParser.new.build(parser, breadcrumbs, config)
|
Parsers::ConfigParser.new.build(parser, breadcrumbs, config)
|
||||||
|
@ -59,7 +59,7 @@ module GX::Parsers
|
||||||
parser.on("mapping", "Manage mappings") do
|
parser.on("mapping", "Manage mappings") do
|
||||||
config.mode = Types::Mode::GlobalHelp
|
config.mode = Types::Mode::GlobalHelp
|
||||||
config.help_options = Parsers::Options::HelpOptions.new
|
config.help_options = Parsers::Options::HelpOptions.new
|
||||||
config.help_options.try(&.parser_snapshot=(parser.dup))
|
config.help_options.try { |opts| opts.parser_snapshot = parser.dup }
|
||||||
|
|
||||||
Parsers::MappingParser.new.build(parser, breadcrumbs, config)
|
Parsers::MappingParser.new.build(parser, breadcrumbs, config)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "./breadcrumbs"
|
||||||
module GX::Utils
|
module GX::Utils
|
||||||
def self.usage_line(breadcrumbs : BreadCrumbs, description : String, has_commands : Bool = false)
|
def self.usage_line(breadcrumbs : BreadCrumbs, description : String, has_commands : Bool = false)
|
||||||
[
|
[
|
||||||
"Usage: #{breadcrumbs}#{has_commands ? " [commands]" : ""} [options]",
|
"Usage: #{breadcrumbs.to_s}#{has_commands ? " [commands]" : ""} [options]",
|
||||||
"",
|
"",
|
||||||
description,
|
description,
|
||||||
"",
|
"",
|
||||||
|
@ -12,6 +12,6 @@ module GX::Utils
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.help_line(breadcrumbs : BreadCrumbs)
|
def self.help_line(breadcrumbs : BreadCrumbs)
|
||||||
"\nRun '#{breadcrumbs} COMMAND --help' for more information on a command."
|
"\nRun '#{breadcrumbs.to_s} COMMAND --help' for more information on a command."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue