Class: Mux::Options

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

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/mux.rb', line 77

def self.parse(args)
  options = OpenStruct.new
  options.verbose = false
  options.to_stdout = false
  options.pipes = []
  options.appends = []
  options.funnels = []
  
  opts = OptionParser.new do |opts|
    opts.banner = "Usage: mux [options]"

    opts.separator ""
    opts.separator "General options:"
    
    opts.on("-s", "Pass stdin to stdout (like tee)") do |s|
      options.to_stdout = true
    end
    
    opts.on("-h", "Show this help message") do
      puts opts
      exit
    end
    
    opts.separator ""
    opts.separator "Target specification options:"
    
    opts.on("-p target1,target2...targetN", Array,
        "List of processes to pipe to") do |pipes|
      options.pipes = pipes
    end
    
    opts.on("-f target1,target2...targetN", Array,
        "List of files to funnel to") do |funnels|
      options.funnels = funnels
    end
    
    opts.on("-a target1,target2...targetN", Array,
        "List of files to append to") do |appends|
      options.appends = appends
    end

  end
  
  opts.parse!(args)
  options 
end