WIP: feat: add scaffold for operations (command design pattern) #31

Closed
glenux wants to merge 17 commits from feature/1-add-support-for-fs-crud into develop
Showing only changes of commit cb99019be5 - Show all commits

View file

@ -5,8 +5,10 @@ module GX::Parsers
class MappingParser < AbstractParser
def build(parser, ancestors, config)
breadcrumbs = ancestors + "mapping"
add_args = {name: "", path: ""}
create_args = {name: "", path: ""}
delete_args = {name: ""}
mount_args = {name: ""}
umount_args = {name: ""}
parser.banner = Utils.usage_line(
breadcrumbs,
@ -28,19 +30,30 @@ module GX::Parsers
parser.separator("\nCreate options")
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
parser.on("-n", "--name", "Set mapping name") do |name|
add_args = add_args.merge({name: name})
create_args = create_args.merge({name: name})
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
parser.on("--remote-host HOST", "Set SSH host") do |host|
add_args = add_args.merge({remote_host: host})
parser.on("--remote-user USER", "Set SSH user (for sshfs)") do |user|
create_args = create_args.merge({remote_user: user})
end
parser.on("--source-path PATH", "Set remote path") do |path|
add_args = add_args.merge({remote_path: path})
parser.on("--remote-host HOST", "Set SSH host (for sshfs)") do |host|
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
parser.separator(Utils.help_line(breadcrumbs + "create"))
@ -50,13 +63,13 @@ module GX::Parsers
config.mode = Types::Mode::MappingEdit
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
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
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
parser.separator(Utils.help_line(breadcrumbs + "edit"))
@ -65,21 +78,35 @@ module GX::Parsers
parser.on("mount", "Mount mapping") do |_|
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"))
# abort("FIXME: Not implemented")
end
parser.on("umount", "Umount mapping") do |_|
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"))
# abort("FIXME: Not implemented")
end
parser.on("delete", "Delete mapping") do
config.mode = Types::Mode::MappingDelete
parser.banner = Utils.usage_line(breadcrumbs + "delete", "Delete mapping", true)
parser.separator("\nDelete options")
parser.banner = Utils.usage_line(breadcrumbs + "delete", "delete mapping", true)
parser.separator("\ndelete options")
parser.on("-n", "--name", "Set mapping name") do |name|
delete_args = delete_args.merge({name: name})