2009-04-03 16:27:49 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
2014-10-29 22:02:45 +00:00
|
|
|
#$DEBUG = true
|
|
|
|
#$VERBOSE = true
|
2010-01-24 18:30:15 +00:00
|
|
|
|
2014-02-23 21:18:26 +00:00
|
|
|
QASIM_INCLUDE_DIR = "lib"
|
|
|
|
QASIM_DATA_DIR = "."
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# external libraries
|
|
|
|
#
|
|
|
|
require 'bundler/setup'
|
2011-03-07 23:52:00 +00:00
|
|
|
require 'pp'
|
2014-10-29 22:02:45 +00:00
|
|
|
require 'thor'
|
2014-02-23 21:18:26 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# project libraries
|
|
|
|
#
|
|
|
|
require 'qasim'
|
2009-05-22 21:01:23 +00:00
|
|
|
|
2011-07-20 22:49:07 +00:00
|
|
|
module Qasim
|
2011-03-10 16:56:54 +00:00
|
|
|
|
2014-10-29 22:36:51 +00:00
|
|
|
class Cli < Thor
|
2014-10-29 22:02:45 +00:00
|
|
|
|
|
|
|
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
|
2011-03-10 16:56:54 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2014-10-29 22:02:45 +00:00
|
|
|
def initializez
|
2011-03-10 16:56:54 +00:00
|
|
|
@all_maps = nil
|
2009-12-14 23:56:06 +00:00
|
|
|
@active_maps = nil
|
2011-03-10 16:56:54 +00:00
|
|
|
|
2009-05-22 21:01:23 +00:00
|
|
|
puts "-- sshfs-mapper --"
|
2011-03-15 16:58:13 +00:00
|
|
|
@config = Config.new
|
|
|
|
@config.parse_cmd_line ARGV
|
|
|
|
@config.parse_file
|
|
|
|
|
|
|
|
@all_maps = {}
|
|
|
|
pp @config
|
2009-05-22 21:01:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-10-29 22:02:45 +00:00
|
|
|
|
2011-03-10 16:56:54 +00:00
|
|
|
# create default map for each selected map
|
|
|
|
# or default.map if none selected
|
|
|
|
def run_init
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_mount
|
|
|
|
|
2011-03-15 16:58:13 +00:00
|
|
|
# asynchronous mount
|
|
|
|
selected_maps = @config.maps.select do |map|
|
2011-03-07 23:52:00 +00:00
|
|
|
pp map
|
2011-03-15 16:58:13 +00:00
|
|
|
map.online?
|
2011-03-10 16:56:54 +00:00
|
|
|
# if map.available? then
|
|
|
|
# map.connect!
|
|
|
|
# end
|
2009-05-22 21:01:23 +00:00
|
|
|
end
|
2011-03-15 16:58:13 +00:00
|
|
|
|
2011-03-10 16:56:54 +00:00
|
|
|
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
|
|
|
|
|
2009-05-22 21:01:23 +00:00
|
|
|
puts "--run"
|
|
|
|
end
|
2009-04-03 16:27:49 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-10-29 22:36:51 +00:00
|
|
|
Qasim::Cli.start(ARGV)
|
2011-03-07 23:25:47 +00:00
|
|
|
|