sshfs-mapper: Fix options & command-line parsing.

git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1662 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
Glenn Y. Rolland 2011-03-10 16:56:34 +00:00
parent c5b81f32ec
commit 3315a351ba
2 changed files with 22 additions and 14 deletions

View file

@ -11,10 +11,17 @@ require 'rdebug/base'
module SshfsMapper
class Config
attr_reader :maps_active
attr_reader :maps
ACTION_UMOUNT = :umount
ACTION_MOUNT = :mount
ACTION_INIT = :init
def initialize
@action = ACTION_MOUNT
user = if ENV['USER'] then
ENV['USER']
else
@ -67,29 +74,30 @@ module SshfsMapper
def parse_cmd_line args
opts = OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options]"
opts.banner = "Usage: #{$0} [action] [options]"
opts.separator ""
opts.separator "Action (mount by default):"
opts.on('-u', '--umount', 'Umount') do |umount|
@action = ACTION_UMOUNT
end
opts.on('-i', '--initialize', 'Populate with default configuration' ) do |init|
@action = ACTION_INIT
end
opts.separator "Specific options:"
opts.on('-a', '--all', 'Mount all targets (disables -s)') do |all|
@all_enable = all
opts.on('-a', '--all', 'Targets all enabled maps (disables -s)') do |all|
@targets_all = all
end
#FIXME: use target list there
opts.on('-s', '--select TARGET', 'Mount only specified target') do |target|
opts.on('-s', '--select TARGET', 'Target selected map (even disabled)') do |target|
@targets << target
end
opts.on('-u', '--umount', 'Umount') do |umount|
@umount_enable = umount
end
opts.on('-i', '--initialize',
'Populate default configuration and example map' ) do |init|
@initialize_enable = init
end
opts.on('-v', '--[no-]verbose', 'Run verbosely' ) do |verbose|
@verbose_enable = verbose
end

View file

@ -16,7 +16,7 @@ module SshfsMapper
end
CYPHER_ARCFOUR = :arcfour
CYPHER_AES256CBC = :"aes-256-cbc"
CYPHER_AES256CBC = "aes-256-cbc".to_sym
CYPHERS = [ CYPHER_ARCFOUR, CYPHER_AES256CBC ]