Compare commits
No commits in common. "a3d827bdb09f8c9677e07f7c808e2da0696cae76" and "ced3168471c0c3cc0edd63270ae373eadf456c44" have entirely different histories.
a3d827bdb0
...
ced3168471
50 changed files with 108 additions and 541 deletions
5
Makefile
5
Makefile
|
@ -11,7 +11,7 @@ prepare:
|
||||||
shards install
|
shards install
|
||||||
|
|
||||||
build:
|
build:
|
||||||
shards build --progress --error-trace -Dpreview_mt
|
shards build --error-trace -Dpreview_mt
|
||||||
@echo SUCCESS
|
@echo SUCCESS
|
||||||
|
|
||||||
watch:
|
watch:
|
||||||
|
@ -21,9 +21,6 @@ spec: test
|
||||||
test:
|
test:
|
||||||
crystal spec --error-trace
|
crystal spec --error-trace
|
||||||
|
|
||||||
format:
|
|
||||||
crystal tool format
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
install \
|
install \
|
||||||
-m 755 \
|
-m 755 \
|
||||||
|
|
5
Vagrantfile
vendored
5
Vagrantfile
vendored
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# -*- mode: ruby -*-
|
# -*- mode: ruby -*-
|
||||||
|
|
|
@ -3,11 +3,5 @@ require "../../src/commands/mapping_create"
|
||||||
|
|
||||||
describe GX::Commands::MappingCreate do
|
describe GX::Commands::MappingCreate do
|
||||||
context "Initialization" do
|
context "Initialization" do
|
||||||
it "initializes with a mock FileSystemManager and RootConfig" do
|
|
||||||
config = GX::Config.new
|
|
||||||
root_config = GX::Models::RootConfig.new
|
|
||||||
command = GX::Commands::MappingCreate.new(config)
|
|
||||||
command.should be_a(GX::Commands::MappingCreate)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,5 @@ require "../../src/commands/mapping_edit"
|
||||||
|
|
||||||
describe GX::Commands::MappingEdit do
|
describe GX::Commands::MappingEdit do
|
||||||
context "Initialization" do
|
context "Initialization" do
|
||||||
it "initializes with a mock FileSystemManager" do
|
|
||||||
config = GX::Config.new
|
|
||||||
command = GX::Commands::MappingEdit.new(config)
|
|
||||||
command.should be_a(GX::Commands::MappingEdit)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,108 +1,7 @@
|
||||||
|
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
require "../../src/commands/mapping_list"
|
require "../../src/commands/mapping_list"
|
||||||
require "../../src/models/gocryptfs_config"
|
|
||||||
require "../../src/models/sshfs_config"
|
|
||||||
require "../../src/models/httpdirfs_config"
|
|
||||||
|
|
||||||
describe GX::Commands::MappingList do
|
describe GX::Commands::MappingList do
|
||||||
context "Initialization" do
|
context "Initialization" do
|
||||||
it "initializes with a mock FileSystemManager and RootConfig" do
|
|
||||||
config = GX::Config.new
|
|
||||||
root_config = GX::Models::RootConfig.new
|
|
||||||
command = GX::Commands::MappingList.new(config)
|
|
||||||
command.should be_a(GX::Commands::MappingList)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "Functioning" do
|
|
||||||
it "lists mappings when there are no filesystems" do
|
|
||||||
config = GX::Config.new
|
|
||||||
root_config = GX::Models::RootConfig.new
|
|
||||||
command = GX::Commands::MappingList.new(config)
|
|
||||||
|
|
||||||
output = capture_output do
|
|
||||||
command.execute
|
|
||||||
end
|
|
||||||
|
|
||||||
output.should include("TYPE")
|
|
||||||
output.should include("NAME")
|
|
||||||
output.should include("MOUNTED")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "lists mappings when there are multiple filesystems" do
|
|
||||||
config = GX::Config.new
|
|
||||||
root_config = GX::Models::RootConfig.new
|
|
||||||
|
|
||||||
gocryptfs_config = GX::Models::GoCryptFSConfig.new(
|
|
||||||
GX::Parsers::Options::MappingCreateOptions.new(
|
|
||||||
type: "gocryptfs",
|
|
||||||
name: "test_gocryptfs",
|
|
||||||
encrypted_path: "/encrypted/path"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
sshfs_config = GX::Models::SshFSConfig.new(
|
|
||||||
GX::Parsers::Options::MappingCreateOptions.new(
|
|
||||||
type: "sshfs",
|
|
||||||
name: "test_sshfs",
|
|
||||||
remote_user: "user",
|
|
||||||
remote_host: "host",
|
|
||||||
remote_path: "/remote/path"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
httpdirfs_config = GX::Models::HttpDirFSConfig.new(
|
|
||||||
GX::Parsers::Options::MappingCreateOptions.new(
|
|
||||||
type: "httpdirfs",
|
|
||||||
name: "test_httpdirfs",
|
|
||||||
url: "http://example.com"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
root_config.add_filesystem(gocryptfs_config)
|
|
||||||
root_config.add_filesystem(sshfs_config)
|
|
||||||
root_config.add_filesystem(httpdirfs_config)
|
|
||||||
|
|
||||||
command = GX::Commands::MappingList.new(config)
|
|
||||||
|
|
||||||
output = capture_output do
|
|
||||||
command.execute
|
|
||||||
end
|
|
||||||
|
|
||||||
output.should include("gocryptfs")
|
|
||||||
output.should include("test_gocryptfs")
|
|
||||||
output.should include("false")
|
|
||||||
|
|
||||||
output.should include("sshfs")
|
|
||||||
output.should include("test_sshfs")
|
|
||||||
output.should include("false")
|
|
||||||
|
|
||||||
output.should include("httpdirfs")
|
|
||||||
output.should include("test_httpdirfs")
|
|
||||||
output.should include("false")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "ensures the output format is correct" do
|
|
||||||
config = GX::Config.new
|
|
||||||
root_config = GX::Models::RootConfig.new
|
|
||||||
config.instance_variable_set("@root", root_config)
|
|
||||||
|
|
||||||
gocryptfs_config = GX::Models::GoCryptFSConfig.new(
|
|
||||||
GX::Parsers::Options::MappingCreateOptions.new(
|
|
||||||
type: "gocryptfs",
|
|
||||||
name: "test_gocryptfs",
|
|
||||||
encrypted_path: "/encrypted/path"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
root_config.add_filesystem(gocryptfs_config)
|
|
||||||
|
|
||||||
command = GX::Commands::MappingList.new(config)
|
|
||||||
|
|
||||||
output = capture_output do
|
|
||||||
command.execute
|
|
||||||
end
|
|
||||||
|
|
||||||
output.should match(/TYPE\s+NAME\s+MOUNTED/)
|
|
||||||
output.should match(/gocryptfs\s+test_gocryptfs\s+false/)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
11
src/cli.cr
11
src/cli.cr
|
@ -30,22 +30,13 @@ module GX
|
||||||
Parsers::RootParser.new.build(parser, breadcrumbs, @config)
|
Parsers::RootParser.new.build(parser, breadcrumbs, @config)
|
||||||
end
|
end
|
||||||
pparser.parse(args)
|
pparser.parse(args)
|
||||||
rescue e : OptionParser::MissingOption
|
|
||||||
STDERR.puts "ERROR: #{e.message}".colorize(:red)
|
|
||||||
exit(1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
command = CommandFactory.create_command(@config, @config.mode)
|
command = CommandFactory.create_command(@config, @config.mode)
|
||||||
abort("ERROR: unknown command for mode #{@config.mode}") if command.nil?
|
abort("ERROR: unknown command for mode #{@config.mode}") if command.nil?
|
||||||
|
|
||||||
command.execute
|
command.try &.execute
|
||||||
rescue e : ArgumentError
|
|
||||||
STDERR.puts "ERROR: #{e.message}".colorize(:red)
|
|
||||||
exit(1)
|
|
||||||
rescue e : Exception
|
|
||||||
STDERR.puts "ERROR: #{e.message}".colorize(:red)
|
|
||||||
exit(1)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./commands"
|
require "./commands"
|
||||||
|
|
||||||
module GX
|
module GX
|
||||||
|
|
|
@ -1,6 +1 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./commands/*"
|
require "./commands/*"
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "../config"
|
require "../config"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
require "../file_storage"
|
require "../file_storage"
|
||||||
|
|
||||||
|
@ -18,7 +13,7 @@ module GX::Commands
|
||||||
# Override the configuration path if provided
|
# Override the configuration path if provided
|
||||||
puts "Configuration file path: #{config_file_path}"
|
puts "Configuration file path: #{config_file_path}"
|
||||||
puts "Configuration file path: #{@config.path}"
|
puts "Configuration file path: #{@config.path}"
|
||||||
# pp @config
|
pp @config
|
||||||
@config.path.try do |path|
|
@config.path.try do |path|
|
||||||
config_file_path = path
|
config_file_path = path
|
||||||
config_dir = File.dirname(path)
|
config_dir = File.dirname(path)
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
require "../file_system_manager"
|
require "../file_system_manager"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class GlobalTui < AbstractCommand
|
class GlobalTui < AbstractCommand
|
||||||
# @file_system_manager : FileSystemManager
|
@file_system_manager : FileSystemManager
|
||||||
|
|
||||||
def initialize(@config : GX::Config)
|
def initialize(@config : GX::Config)
|
||||||
@config.load_from_env
|
@config.load_from_env
|
||||||
@config.load_from_file
|
@config.load_from_file
|
||||||
# @file_system_manager = FileSystemManager.new(@config)
|
@file_system_manager = FileSystemManager.new(@config)
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
# raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
filesystem = @file_system_manager.choose_filesystem
|
||||||
# @file_system_manager.mount_or_umount(filesystem)
|
raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
||||||
# @file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open?
|
@file_system_manager.mount_or_umount(filesystem)
|
||||||
|
@file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
require "../config"
|
require "../config"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class GlobalVersion < AbstractCommand
|
class GlobalVersion < AbstractCommand
|
||||||
def initialize(config : GX::Config)
|
def initialize(config : GX::Config) # FIXME
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
|
|
|
@ -1,57 +1,58 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
require "../models/filesystem_factory"
|
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class MappingCreate < AbstractCommand
|
class MappingCreate < AbstractCommand
|
||||||
def initialize(@config : GX::Config)
|
def initialize(@config : GX::Config) # FIXME
|
||||||
@config.load_from_env
|
@config.load_from_env
|
||||||
@config.load_from_file
|
@config.load_from_file
|
||||||
@config.save_to_file
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
# Assuming mapping_create_options is passed to this command with necessary details
|
# FIXME: verify that filesystem is valid or return an error
|
||||||
create_options = @config.mapping_create_options
|
|
||||||
|
# Assuming create_args is passed to this command with necessary details
|
||||||
|
create_args = @config.create_args
|
||||||
|
|
||||||
# Validate required arguments
|
# Validate required arguments
|
||||||
if create_options.nil?
|
if create_args[:name].empty? || create_args[:path].empty?
|
||||||
raise ArgumentError.new("Mapping create options are required")
|
raise ArgumentError.new("Name and path are required to create a mapping.")
|
||||||
end
|
|
||||||
if create_options.name.nil? || create_options.name.try &.empty?
|
|
||||||
raise ArgumentError.new("Name is required to create a mapping.")
|
|
||||||
end
|
|
||||||
if create_options.type.nil? || create_options.type.try &.empty?
|
|
||||||
raise ArgumentError.new("Type is required to create a mapping.")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create the appropriate filesystem config based on the type
|
# Create the appropriate filesystem config based on the type
|
||||||
filesystem_config = GX::Models::FilesystemFactory.build(create_options)
|
filesystem_config = case create_args[:type]
|
||||||
|
when "gocryptfs"
|
||||||
# Append the new filesystem config to the root config
|
GX::Models::GocryptfsConfig.new(
|
||||||
@config.root.try do |root|
|
name: create_args[:name],
|
||||||
root.filesystems ||= [] of GX::Models::AbstractFilesystemConfig
|
path: create_args[:path],
|
||||||
root.filesystems << filesystem_config
|
encrypted_path: create_args[:encrypted_path]
|
||||||
|
)
|
||||||
|
when "sshfs"
|
||||||
|
GX::Models::SshfsConfig.new(
|
||||||
|
name: create_args[:name],
|
||||||
|
path: create_args[:path],
|
||||||
|
remote_user: create_args[:remote_user],
|
||||||
|
remote_host: create_args[:remote_host],
|
||||||
|
remote_path: create_args[:remote_path],
|
||||||
|
remote_port: create_args[:remote_port]
|
||||||
|
)
|
||||||
|
when "httpdirfs"
|
||||||
|
GX::Models::HttpdirfsConfig.new(
|
||||||
|
name: create_args[:name],
|
||||||
|
path: create_args[:path],
|
||||||
|
url: create_args[:url]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
raise ArgumentError.new("Unsupported mapping type: #{create_args[:type]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Mapping '#{create_options.name}' created and added to configuration successfully."
|
# Append the new filesystem config to the root config
|
||||||
|
@config.root.try &.filesystems << filesystem_config
|
||||||
|
|
||||||
|
puts "Mapping '#{create_args[:name]}' created and added to configuration successfully."
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
GX::Types::Mode::MappingCreate
|
GX::Types::Mode::MappingCreate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# validate create_options.PARAMETER and display error with description if
|
|
||||||
# missing
|
|
||||||
macro option_check(create_options, parameter, description)
|
|
||||||
if create_options.{{ parameter.id }}.nil? || create_options.{{ parameter.id }}.try &.empty?
|
|
||||||
raise ArgumentError.new("Parameter for " + {{description}} + " is required")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class MappingDelete < AbstractCommand
|
class MappingDelete < AbstractCommand
|
||||||
def initialize(config : GX::Config)
|
def initialize(config : GX::Config) # FIXME
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
# TODO: implement
|
# FIXME: implement
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class MappingEdit < AbstractCommand
|
class MappingEdit < AbstractCommand
|
||||||
def initialize(config : GX::Config)
|
def initialize(config : GX::Config) # FIXME
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
# TODO: implement
|
# FIXME: implement
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
require "../file_system_manager"
|
require "../file_system_manager"
|
||||||
require "tablo"
|
require "tablo"
|
||||||
|
@ -12,6 +7,7 @@ module GX::Commands
|
||||||
def initialize(@config : GX::Config)
|
def initialize(@config : GX::Config)
|
||||||
@config.load_from_env
|
@config.load_from_env
|
||||||
@config.load_from_file
|
@config.load_from_file
|
||||||
|
@file_system_manager = FileSystemManager.new(@config)
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
|
|
|
@ -1,39 +1,25 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
require "../file_system_manager"
|
require "../file_system_manager"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class MappingMount < AbstractCommand
|
class MappingMount < AbstractCommand
|
||||||
# @file_system_manager : FileSystemManager
|
@file_system_manager : FileSystemManager
|
||||||
|
|
||||||
def initialize(@config : GX::Config)
|
def initialize(@config : GX::Config)
|
||||||
@config.load_from_env
|
@config.load_from_env
|
||||||
@config.load_from_file
|
@config.load_from_file
|
||||||
|
@file_system_manager = FileSystemManager.new(@config)
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
# filesystem = @config.root.try &.file_system_manager.choose_filesystem
|
filesystem = @file_system_manager.choose_filesystem
|
||||||
# raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
||||||
# filesystem.mount
|
filesystem.mount
|
||||||
# @file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open?
|
@file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
GX::Types::Mode::MappingMount
|
GX::Types::Mode::MappingMount
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _mount_filesystem(filesystem : Models::AbstractFilesystemConfig)
|
|
||||||
raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
|
||||||
if filesystem.mounted?
|
|
||||||
Log.info { "Filesystem already mounted." }
|
|
||||||
return
|
|
||||||
end
|
|
||||||
filesystem.mount
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,40 +1,24 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./abstract_command"
|
require "./abstract_command"
|
||||||
require "../file_system_manager"
|
require "../file_system_manager"
|
||||||
|
|
||||||
module GX::Commands
|
module GX::Commands
|
||||||
class MappingUmount < AbstractCommand
|
class MappingUmount < AbstractCommand
|
||||||
|
@file_system_manager : FileSystemManager
|
||||||
|
|
||||||
def initialize(@config : GX::Config)
|
def initialize(@config : GX::Config)
|
||||||
@config.load_from_env
|
@config.load_from_env
|
||||||
@config.load_from_file
|
@config.load_from_file
|
||||||
|
@file_system_manager = FileSystemManager.new(@config)
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
# root = @config.root
|
filesystem = @file_system_manager.choose_filesystem
|
||||||
# raise "Missing root config" if root.nil?
|
raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
||||||
|
filesystem.umount
|
||||||
# filesystem = root.file_system_manager.choose_filesystem
|
|
||||||
# raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
|
||||||
|
|
||||||
# filesystem.umount
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.handles_mode
|
def self.handles_mode
|
||||||
GX::Types::Mode::MappingUmount
|
GX::Types::Mode::MappingUmount
|
||||||
end
|
end
|
||||||
|
|
||||||
# OBSOLETE:
|
|
||||||
private def umount_filesystem(filesystem : Models::AbstractFilesystemConfig)
|
|
||||||
raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
|
||||||
unless filesystem.mounted?
|
|
||||||
Log.info { "Filesystem is not mounted." }
|
|
||||||
return
|
|
||||||
end
|
|
||||||
filesystem.umount
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,20 +27,20 @@ module GX
|
||||||
record AddArgs, name : String, path : String
|
record AddArgs, name : String, path : String
|
||||||
record DelArgs, name : String
|
record DelArgs, name : String
|
||||||
|
|
||||||
|
# getter filesystems : Array(Models::AbstractFilesystemConfig)
|
||||||
getter home_dir : String
|
getter home_dir : String
|
||||||
getter root : Models::RootConfig?
|
getter root : Models::RootConfig?
|
||||||
|
|
||||||
property? verbose : Bool
|
property verbose : Bool
|
||||||
property mode : Types::Mode
|
property mode : Types::Mode
|
||||||
property path : String?
|
property path : String?
|
||||||
property args : AddArgs.class | DelArgs.class | NoArgs.class
|
property args : AddArgs.class | DelArgs.class | NoArgs.class
|
||||||
property? auto_open : Bool
|
property auto_open : Bool
|
||||||
|
|
||||||
# TODO: refactor and remove these parts from here
|
# FIXME: refactor and remove these parts from here
|
||||||
|
property help_options : Parsers::Options::HelpOptions?
|
||||||
property config_init_options : Parsers::Options::ConfigInitOptions?
|
property config_init_options : Parsers::Options::ConfigInitOptions?
|
||||||
property config_options : Parsers::Options::ConfigOptions?
|
property config_options : Parsers::Options::ConfigOptions?
|
||||||
property help_options : Parsers::Options::HelpOptions?
|
|
||||||
property mapping_create_options : Parsers::Options::MappingCreateOptions?
|
|
||||||
property mapping_create_options : Parsers::Options::MappingCreateOptions?
|
property mapping_create_options : Parsers::Options::MappingCreateOptions?
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -102,12 +102,7 @@ module GX
|
||||||
file_data = File.read(config_path)
|
file_data = File.read(config_path)
|
||||||
file_patched = Crinja.render(file_data, {"env" => ENV.to_h})
|
file_patched = Crinja.render(file_data, {"env" => ENV.to_h})
|
||||||
|
|
||||||
begin
|
root = Models::RootConfig.from_yaml(file_patched)
|
||||||
root = Models::RootConfig.from_yaml(file_patched)
|
|
||||||
rescue ex : YAML::ParseException
|
|
||||||
STDERR.puts "Error parsing configuration file: #{ex.message}".colorize(:red)
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
mount_point_base_safe = root.global.mount_point_base
|
mount_point_base_safe = root.global.mount_point_base
|
||||||
raise Models::InvalidMountpointError.new("Invalid global mount point") if mount_point_base_safe.nil?
|
raise Models::InvalidMountpointError.new("Invalid global mount point") if mount_point_base_safe.nil?
|
||||||
|
@ -120,15 +115,5 @@ module GX
|
||||||
end
|
end
|
||||||
@root = root
|
@root = root
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_to_file
|
|
||||||
return if @path.nil?
|
|
||||||
if @path
|
|
||||||
File.write(@path.to_s, @root.to_yaml)
|
|
||||||
else
|
|
||||||
Log.error { "Configuration path is nil, cannot save configuration." }
|
|
||||||
end
|
|
||||||
Log.info { "Configuration saved to #{@path}" }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "baked_file_system"
|
require "baked_file_system"
|
||||||
|
|
||||||
class FileStorage
|
class FileStorage
|
||||||
|
@ -10,3 +5,4 @@ class FileStorage
|
||||||
|
|
||||||
bake_folder "../static"
|
bake_folder "../static"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
# require "./models/abstract_filesystem_config"
|
# require "./models/abstract_filesystem_config"
|
||||||
require "./utils/fzf"
|
require "./utils/fzf"
|
||||||
|
|
||||||
|
@ -13,6 +8,25 @@ module GX
|
||||||
def initialize(@config : Config)
|
def initialize(@config : Config)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# OBSOLETE:
|
||||||
|
# def mount_filesystem(filesystem : Models::AbstractFilesystemConfig)
|
||||||
|
# raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
||||||
|
# if filesystem.mounted?
|
||||||
|
# Log.info { "Filesystem already mounted." }
|
||||||
|
# return
|
||||||
|
# end
|
||||||
|
# filesystem.mount
|
||||||
|
# end
|
||||||
|
|
||||||
|
# OBSOLETE:
|
||||||
|
# def umount_filesystem(filesystem : Models::AbstractFilesystemConfig)
|
||||||
|
# raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil?
|
||||||
|
# unless filesystem.mounted?
|
||||||
|
# Log.info { "Filesystem is not mounted." }
|
||||||
|
# return
|
||||||
|
# end
|
||||||
|
# filesystem.umount
|
||||||
|
# end
|
||||||
|
|
||||||
def mount_or_umount(selected_filesystem)
|
def mount_or_umount(selected_filesystem)
|
||||||
if !selected_filesystem.mounted?
|
if !selected_filesystem.mounted?
|
||||||
|
@ -23,10 +37,10 @@ module GX
|
||||||
end
|
end
|
||||||
|
|
||||||
def auto_open(filesystem)
|
def auto_open(filesystem)
|
||||||
# TODO: detect xdg-open and use it if possible
|
# FIXME: detect xdg-open and use it if possible
|
||||||
# TODO: detect mailcap and use it if no xdg-open found
|
# FIXME: detect mailcap and use it if no xdg-open found
|
||||||
# TODO: support user-defined command in configuration
|
# FIXME: support user-defined command in configuration
|
||||||
# TODO: detect graphical environment
|
# FIXME: detect graphical environment
|
||||||
|
|
||||||
mount_point_safe = filesystem.mount_point
|
mount_point_safe = filesystem.mount_point
|
||||||
raise Models::InvalidMountpointError.new("Invalid filesystem") if mount_point_safe.nil?
|
raise Models::InvalidMountpointError.new("Invalid filesystem") if mount_point_safe.nil?
|
||||||
|
@ -92,7 +106,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!(&.[: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]
|
||||||
|
|
|
@ -15,15 +15,6 @@ module GX::Models
|
||||||
abstract class AbstractFilesystemConfig
|
abstract class AbstractFilesystemConfig
|
||||||
include YAML::Serializable
|
include YAML::Serializable
|
||||||
# include YAML::Serializable::Strict
|
# include YAML::Serializable::Strict
|
||||||
@@subs = [] of AbstractFilesystemConfig.class
|
|
||||||
|
|
||||||
macro inherited
|
|
||||||
@@subs << {{@type.name.id}}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.subs
|
|
||||||
@@subs
|
|
||||||
end
|
|
||||||
|
|
||||||
use_yaml_discriminator "type", {
|
use_yaml_discriminator "type", {
|
||||||
gocryptfs: GoCryptFSConfig,
|
gocryptfs: GoCryptFSConfig,
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
module GX::Models::Concerns
|
module GX::Models::Concerns
|
||||||
module Base
|
module Base
|
||||||
def mounted? : Bool
|
def mounted? : Bool
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
module GX::Models
|
|
||||||
class FilesystemFactory
|
|
||||||
def self.build(create_options)
|
|
||||||
case create_options.type
|
|
||||||
when "gocryptfs"
|
|
||||||
GoCryptFSConfig.new(create_options)
|
|
||||||
when "sshfs"
|
|
||||||
SshFSConfig.new(create_options)
|
|
||||||
when "httpdirfs"
|
|
||||||
HttpDirFSConfig.new(create_options)
|
|
||||||
else
|
|
||||||
raise ArgumentError.new("Unsupported mapping type: #{create_options.type}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -13,11 +13,6 @@ module GX::Models
|
||||||
|
|
||||||
include Concerns::Base
|
include Concerns::Base
|
||||||
|
|
||||||
def initialize(create_options)
|
|
||||||
@name = create_options.name.as(String)
|
|
||||||
@encrypted_path = create_options.encrypted_path.as(String)
|
|
||||||
end
|
|
||||||
|
|
||||||
def _mounted_prefix
|
def _mounted_prefix
|
||||||
"#{encrypted_path}"
|
"#{encrypted_path}"
|
||||||
end
|
end
|
||||||
|
@ -39,6 +34,5 @@ module GX::Models
|
||||||
)
|
)
|
||||||
process.wait
|
process.wait
|
||||||
end
|
end
|
||||||
def self.name ; "gocryptfs" ; end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,11 +13,6 @@ module GX::Models
|
||||||
|
|
||||||
include Concerns::Base
|
include Concerns::Base
|
||||||
|
|
||||||
def initialize(create_options)
|
|
||||||
@name = create_options.name.as(String)
|
|
||||||
@url = create_options.url.as(String)
|
|
||||||
end
|
|
||||||
|
|
||||||
def _mounted_prefix
|
def _mounted_prefix
|
||||||
"httpdirfs"
|
"httpdirfs"
|
||||||
end
|
end
|
||||||
|
@ -39,6 +34,5 @@ module GX::Models
|
||||||
)
|
)
|
||||||
process.wait
|
process.wait
|
||||||
end
|
end
|
||||||
def self.name ; "httpdirfs" ; end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,12 +36,5 @@ module GX::Models
|
||||||
|
|
||||||
@[YAML::Field(key: "filesystems")]
|
@[YAML::Field(key: "filesystems")]
|
||||||
getter filesystems : Array(AbstractFilesystemConfig)
|
getter filesystems : Array(AbstractFilesystemConfig)
|
||||||
setter filesystems
|
|
||||||
|
|
||||||
def initialize(version = "1.0.0", global = GlobalConfig.new, filesystems = [] of AbstractFilesystemConfig)
|
|
||||||
@version = version
|
|
||||||
@global = global
|
|
||||||
@filesystems = filesystems
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,14 +16,6 @@ module GX::Models
|
||||||
|
|
||||||
include Concerns::Base
|
include Concerns::Base
|
||||||
|
|
||||||
def initialize(create_options)
|
|
||||||
@name = create_options.name.as(String)
|
|
||||||
@remote_user = create_options.remote_user.as(String)
|
|
||||||
@remote_host = create_options.remote_host.as(String)
|
|
||||||
@remote_path = create_options.remote_path.as(String)
|
|
||||||
@remote_port = create_options.remote_port.as(String)
|
|
||||||
end
|
|
||||||
|
|
||||||
def _mounted_prefix
|
def _mounted_prefix
|
||||||
"#{@remote_user}@#{@remote_host}:#{@remote_path}"
|
"#{@remote_user}@#{@remote_host}:#{@remote_path}"
|
||||||
end
|
end
|
||||||
|
@ -49,6 +41,5 @@ module GX::Models
|
||||||
)
|
)
|
||||||
process.wait
|
process.wait
|
||||||
end
|
end
|
||||||
def self.name ; "sshfs" ; end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
module GX::Parsers
|
module GX::Parsers
|
||||||
abstract class AbstractParser
|
abstract class AbstractParser
|
||||||
abstract def build(parser : OptionParser, ancestors : BreadCrumbs, config : Config)
|
abstract def build(parser : OptionParser, ancestors : BreadCrumbs, config : Config)
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./base.cr"
|
require "./base.cr"
|
||||||
|
|
||||||
module GX::Parsers
|
module GX::Parsers
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./options/config_options"
|
require "./options/config_options"
|
||||||
require "./options/config_init_options"
|
require "./options/config_init_options"
|
||||||
require "./base"
|
require "./base"
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./base.cr"
|
require "./base.cr"
|
||||||
require "../utils/parser_lines"
|
require "../utils/parser_lines"
|
||||||
|
|
||||||
|
@ -10,6 +5,7 @@ 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"
|
||||||
|
create_args = {name: "", path: ""}
|
||||||
delete_args = {name: ""}
|
delete_args = {name: ""}
|
||||||
mount_args = {name: ""}
|
mount_args = {name: ""}
|
||||||
umount_args = {name: ""}
|
umount_args = {name: ""}
|
||||||
|
@ -28,53 +24,35 @@ module GX::Parsers
|
||||||
|
|
||||||
parser.on("create", "Create mapping") do
|
parser.on("create", "Create mapping") do
|
||||||
config.mode = Types::Mode::MappingCreate
|
config.mode = Types::Mode::MappingCreate
|
||||||
config.mode = Types::Mode::MappingCreate
|
# pp parser
|
||||||
config.mapping_create_options = Parsers::Options::MappingCreateOptions.new
|
|
||||||
|
|
||||||
parser.banner = Utils.usage_line(breadcrumbs + "create", "Create mapping", true)
|
parser.banner = Utils.usage_line(breadcrumbs + "create", "Create mapping", true)
|
||||||
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|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({type: type})
|
||||||
opts.type = type
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("-n", "--name NAME", "Set mapping name") do |name|
|
parser.on("-n", "--name", "Set mapping name") do |name|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({name: name})
|
||||||
opts.name = name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Filesystem specific
|
# Filesystem specific
|
||||||
parser.on("--encrypted-path PATH", "Set encrypted path (for gocryptfs)") do |path|
|
parser.on("--encrypted-path PATH", "Set encrypted path (for gocryptfs)") do |path|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({encrypted_path: path})
|
||||||
opts.encrypted_path = path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("--remote-user USER", "Set SSH user (for sshfs)") do |user|
|
parser.on("--remote-user USER", "Set SSH user (for sshfs)") do |user|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({remote_user: user})
|
||||||
opts.remote_user = user
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("--remote-host HOST", "Set SSH host (for sshfs)") do |host|
|
parser.on("--remote-host HOST", "Set SSH host (for sshfs)") do |host|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({remote_host: host})
|
||||||
opts.remote_host = host
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("--source-path PATH", "Set remote path (for sshfs)") do |path|
|
parser.on("--source-path PATH", "Set remote path (for sshfs)") do |path|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({remote_path: path})
|
||||||
opts.remote_path = path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("--remote-port PORT", "Set SSH port (for sshfs)") do |port|
|
parser.on("--remote-port PORT", "Set SSH port (for sshfs)") do |port|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({remote_port: port})
|
||||||
opts.remote_port = port
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("--url URL", "Set URL (for httpdirfs)") do |url|
|
parser.on("--url URL", "Set URL (for httpdirfs)") do |url|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({url: url})
|
||||||
opts.url = url
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "create"))
|
parser.separator(Utils.help_line(breadcrumbs + "create"))
|
||||||
|
@ -84,19 +62,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|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({remote_user: user})
|
||||||
opts.remote_user = user
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("--remote-host HOST", "Set SSH host") do |host|
|
parser.on("--remote-host HOST", "Set SSH host") do |host|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({remote_host: host})
|
||||||
opts.remote_host = host
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
parser.on("--source-path PATH", "Set remote path") do |path|
|
parser.on("--source-path PATH", "Set remote path") do |path|
|
||||||
config.mapping_create_options.try do |opts|
|
create_args = create_args.merge({remote_path: path})
|
||||||
opts.remote_path = path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.separator(Utils.help_line(breadcrumbs + "edit"))
|
parser.separator(Utils.help_line(breadcrumbs + "edit"))
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
|
|
||||||
module GX::Parsers::Options
|
module GX::Parsers::Options
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
|
|
||||||
module GX::Parsers::Options
|
module GX::Parsers::Options
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
|
|
||||||
module GX::Parsers::Options
|
module GX::Parsers::Options
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "option_parser"
|
|
||||||
|
|
||||||
module GX::Parsers::Options
|
|
||||||
class MappingCreateOptions
|
|
||||||
property type : String?
|
|
||||||
property name : String?
|
|
||||||
property encrypted_path : String?
|
|
||||||
property remote_user : String?
|
|
||||||
property remote_host : String?
|
|
||||||
property remote_path : String?
|
|
||||||
property remote_port : String?
|
|
||||||
property url : String?
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "option_parser"
|
|
||||||
|
|
||||||
module GX::Parsers::Options
|
|
||||||
class MappingDeleteOptions
|
|
||||||
# Add your options here
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "option_parser"
|
|
||||||
|
|
||||||
module GX::Parsers::Options
|
|
||||||
class MappingMountOptions
|
|
||||||
# Add your options here
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "option_parser"
|
|
||||||
|
|
||||||
module GX::Parsers::Options
|
|
||||||
class MappingUmountOptions
|
|
||||||
# Add your options here
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./base"
|
require "./base"
|
||||||
require "./config_parser"
|
require "./config_parser"
|
||||||
require "./mapping_parser"
|
require "./mapping_parser"
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
module GX::Types
|
module GX::Types
|
||||||
enum Mode
|
enum Mode
|
||||||
None
|
None
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
module GX::Utils
|
module GX::Utils
|
||||||
class BreadCrumbs
|
class BreadCrumbs
|
||||||
def initialize(base : Array(String))
|
def initialize(base : Array(String))
|
||||||
|
|
|
@ -28,8 +28,7 @@ module GX::Utils
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
# result
|
result = output.to_s.strip # .split.first?
|
||||||
output.to_s.strip
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "./breadcrumbs"
|
require "./breadcrumbs"
|
||||||
|
|
||||||
module GX::Utils
|
module GX::Utils
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
require "version_from_shard"
|
require "version_from_shard"
|
||||||
|
|
||||||
module GX
|
module GX
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
# mfm Bash completion script
|
# mfm Bash completion script
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2024 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue