WIP: feature/43-add-support-for-completion-commands #44
1 changed files with 43 additions and 16 deletions
|
@ -5,8 +5,10 @@ module GX::Parsers
|
||||||
class MappingParser < AbstractParser
|
class MappingParser < AbstractParser
|
||||||
def build(parser, ancestors, config)
|
def build(parser, ancestors, config)
|
||||||
breadcrumbs = ancestors + "mapping"
|
breadcrumbs = ancestors + "mapping"
|
||||||
add_args = {name: "", path: ""}
|
create_args = {name: "", path: ""}
|
||||||
delete_args = {name: ""}
|
delete_args = {name: ""}
|
||||||
|
mount_args = {name: ""}
|
||||||
|
umount_args = {name: ""}
|
||||||
|
|
||||||
parser.banner = Utils.usage_line(
|
parser.banner = Utils.usage_line(
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
|
@ -28,19 +30,30 @@ module GX::Parsers
|
||||||
parser.separator("\nCreate options")
|
parser.separator("\nCreate options")
|
||||||
|
|
||||||
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})
|
create_args = create_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})
|
create_args = create_args.merge({name: name})
|
||||||
end
|
end
|
||||||
parser.on("--remote-user USER", "Set SSH user") do |user|
|
|
||||||
add_args = add_args.merge({remote_user: user})
|
# Filesystem specific
|
||||||
|
parser.on("--encrypted-path PATH", "Set encrypted path (for gocryptfs)") do |path|
|
||||||
|
encrypted_path = path
|
||||||
end
|
end
|
||||||
parser.on("--remote-host HOST", "Set SSH host") do |host|
|
parser.on("--remote-user USER", "Set SSH user (for sshfs)") do |user|
|
||||||
add_args = add_args.merge({remote_host: host})
|
create_args = create_args.merge({remote_user: user})
|
||||||
end
|
end
|
||||||
parser.on("--source-path PATH", "Set remote path") do |path|
|
parser.on("--remote-host HOST", "Set SSH host (for sshfs)") do |host|
|
||||||
add_args = add_args.merge({remote_path: path})
|
create_args = create_args.merge({remote_host: host})
|
||||||
|
end
|
||||||
|
parser.on("--source-path PATH", "Set remote path (for sshfs)") do |path|
|
||||||
|
create_args = create_args.merge({remote_path: path})
|
||||||
|
end
|
||||||
|
parser.on("--remote-port PORT", "Set SSH port (for sshfs)") do |port|
|
||||||
|
create_args = create_args.merge({remote_port: port})
|
||||||
|
end
|
||||||
|
parser.on("--url URL", "Set URL (for httpdirfs)") do |url|
|
||||||
|
create_args = create_args.merge({url: url})
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "create"))
|
parser.separator(Utils.help_line(breadcrumbs + "create"))
|
||||||
|
@ -50,13 +63,13 @@ module GX::Parsers
|
||||||
config.mode = Types::Mode::MappingEdit
|
config.mode = Types::Mode::MappingEdit
|
||||||
|
|
||||||
parser.on("--remote-user USER", "Set SSH user") do |user|
|
parser.on("--remote-user USER", "Set SSH user") do |user|
|
||||||
add_args = add_args.merge({remote_user: user})
|
create_args = create_args.merge({remote_user: user})
|
||||||
end
|
end
|
||||||
parser.on("--remote-host HOST", "Set SSH host") do |host|
|
parser.on("--remote-host HOST", "Set SSH host") do |host|
|
||||||
add_args = add_args.merge({remote_host: host})
|
create_args = create_args.merge({remote_host: host})
|
||||||
end
|
end
|
||||||
parser.on("--source-path PATH", "Set remote path") do |path|
|
parser.on("--source-path PATH", "Set remote path") do |path|
|
||||||
add_args = add_args.merge({remote_path: path})
|
create_args = create_args.merge({remote_path: path})
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "edit"))
|
parser.separator(Utils.help_line(breadcrumbs + "edit"))
|
||||||
|
@ -65,21 +78,35 @@ module GX::Parsers
|
||||||
|
|
||||||
parser.on("mount", "Mount mapping") do |_|
|
parser.on("mount", "Mount mapping") do |_|
|
||||||
config.mode = Types::Mode::MappingMount
|
config.mode = Types::Mode::MappingMount
|
||||||
|
|
||||||
|
parser.banner = Utils.usage_line(breadcrumbs + "mount", "mount mapping", true)
|
||||||
|
parser.separator("\nMount options")
|
||||||
|
|
||||||
|
parser.on("-n", "--name", "Set mapping name") do |name|
|
||||||
|
mount_args = mount_args.merge({name: name})
|
||||||
|
end
|
||||||
|
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "mount"))
|
parser.separator(Utils.help_line(breadcrumbs + "mount"))
|
||||||
# abort("FIXME: Not implemented")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("umount", "Umount mapping") do |_|
|
parser.on("umount", "Umount mapping") do |_|
|
||||||
config.mode = Types::Mode::MappingUmount
|
config.mode = Types::Mode::MappingUmount
|
||||||
|
|
||||||
|
parser.banner = Utils.usage_line(breadcrumbs + "umount", "umount mapping", true)
|
||||||
|
parser.separator("\nUmount options")
|
||||||
|
|
||||||
|
parser.on("-n", "--name", "Set mapping name") do |name|
|
||||||
|
umount_args = umount_args.merge({name: name})
|
||||||
|
end
|
||||||
|
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "umount"))
|
parser.separator(Utils.help_line(breadcrumbs + "umount"))
|
||||||
# abort("FIXME: Not implemented")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("delete", "Delete mapping") do
|
parser.on("delete", "Delete mapping") do
|
||||||
config.mode = Types::Mode::MappingDelete
|
config.mode = Types::Mode::MappingDelete
|
||||||
|
|
||||||
parser.banner = Utils.usage_line(breadcrumbs + "delete", "Delete mapping", true)
|
parser.banner = Utils.usage_line(breadcrumbs + "delete", "delete mapping", true)
|
||||||
parser.separator("\nDelete options")
|
parser.separator("\ndelete options")
|
||||||
|
|
||||||
parser.on("-n", "--name", "Set mapping name") do |name|
|
parser.on("-n", "--name", "Set mapping name") do |name|
|
||||||
delete_args = delete_args.merge({name: name})
|
delete_args = delete_args.merge({name: name})
|
||||||
|
|
Loading…
Reference in a new issue