Class: RFuseFlacToMovFSOpts

Inherits:
Object
  • Object
show all
Defined in:
lib/rfuse_flac_to_mov_fs_opts.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object

Return a structure describing the options.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rfuse_flac_to_mov_fs_opts.rb', line 11

def self.parse(args)
  @VERSION = "0.0.2"
  
  # The options specified on the command line will be collected in *options*.
  # We set default values here.
  options = OpenStruct.new
  
  options.verbose = false
  options.mountpoint = ""
  options.input   = ""
   

  opts = OptionParser.new do |opts|
     opts.banner = "Usage: #{__FILE__} [options]"
     opts.separator ""
     opts.separator "Common options:"

     # No argument, shows at tail. This will print an options summary.
     opts.on("-h", "--help", "Show this message") do
        puts opts
        exit
     end

     # Another typical switch to print the version.
     opts.on("--version", "Show version") do
        #puts OptionParser::Version.join('.')
        puts "Version #{@VERSION}"
        exit
     end

     # Boolean switch.
     #opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
     #   options.verbose = v
     #end

     opts.separator ""
     opts.separator "Specific options:"


     # Cast 'delay' argument to a Float.
     opts.on("--mountpoint path", String, "Root of new Filesystem") do |n|
        options.mountpoint = n
     end
     
     opts.on("--input N", String, "Folder FS will point to") do |n|
        options.input = File.expand_path( n )
     end
     
    
  end
  
  options.leftovers = opts.parse!(args)

  if (options.mountpoint == "") and (options.input == "") and (options.leftovers.size==2)
     options.mountpoint = options.leftovers[0]
     options.input      =  File.expand_path( options.leftovers[1] )
  end
  return options
end