diff --git a/bin/qasim-cli b/bin/qasim-cli index 9fa7f2d..1f1d360 100755 --- a/bin/qasim-cli +++ b/bin/qasim-cli @@ -8,92 +8,11 @@ # require 'bundler/setup' require 'pp' -require 'thor' # # project libraries # require 'qasim' -module Qasim - - class Cli < Thor - - desc "init", "initialize user configuration" - def init - raise NotImplementedError - end - - desc "list", "list" - def list - raise NotImplementedError - end - - desc "mount MAPS", "mount selected maps" - def mount - raise NotImplementedError - end - - private - # - # - # - def initializez - @all_maps = nil - @active_maps = nil - - puts "-- sshfs-mapper --" - @config = Config.new - @config.parse_cmd_line ARGV - @config.parse_file - - @all_maps = {} - pp @config - end - - - - # create default map for each selected map - # or default.map if none selected - def run_init - end - - def run_mount - - # asynchronous mount - selected_maps = @config.maps.select do |map| - pp map - map.online? - # if map.available? then - # map.connect! - # end - end - - end - - def run_umount - end - - # - # - # - def run - case @config.action - when Config::ACTION_INIT - run_init - when Config::ACTION_MOUNT - run_mount - when Config::ACTION_UMOUNT - run_umount - else - raise RuntimeError, "Unknown action" - end - - puts "--run" - end - - end -end - Qasim::Cli.start(ARGV) diff --git a/lib/qasim.rb b/lib/qasim.rb index 1c141d4..0cf93e1 100644 --- a/lib/qasim.rb +++ b/lib/qasim.rb @@ -1,11 +1,10 @@ - -require 'qasim/version' require 'qasim/constants' module Qasim autoload :Config, 'qasim/config' autoload :Map, 'qasim/map' autoload :Ui, 'qasim/ui' + autoload :Cli, 'qasim/cli' end diff --git a/lib/qasim/cli.rb b/lib/qasim/cli.rb new file mode 100644 index 0000000..7a81bcd --- /dev/null +++ b/lib/qasim/cli.rb @@ -0,0 +1,78 @@ +require 'thor' + +module Qasim + class Cli < Thor + desc "init", "initialize user configuration" + def init + raise NotImplementedError + end + + desc "list", "list" + def list + raise NotImplementedError + end + + desc "mount MAPS", "mount selected maps" + def mount + raise NotImplementedError + end + + private + # + # + # + def initializez + @all_maps = nil + @active_maps = nil + + puts "-- sshfs-mapper --" + @config = Config.new + @config.parse_cmd_line ARGV + @config.parse_file + + @all_maps = {} + pp @config + end + + + + # create default map for each selected map + # or default.map if none selected + def run_init + end + + def run_mount + # asynchronous mount + selected_maps = @config.maps.select do |map| + pp map + map.online? + # if map.available? then + # map.connect! + # end + end + end + + def run_umount + end + + # + # + # + def run + case @config.action + when Config::ACTION_INIT + run_init + when Config::ACTION_MOUNT + run_mount + when Config::ACTION_UMOUNT + run_umount + else + raise RuntimeError, "Unknown action" + end + + puts "--run" + end + + end +end +