Class: Raykit::Parser
- Inherits:
-
Object
- Object
- Raykit::Parser
- Defined in:
- lib/raykit/console.rb
Overview
Parses the command line arguments for the Raykit console application
Class Method Summary collapse
Class Method Details
.parse(options) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/raykit/console.rb', line 149 def self.parse() hash=Hash.new opt_parser = OptionParser.new do |opts| opts. = "Usage: raykit [options]" opts.on('-l','--list [PATTERN]','list remotes') do |pattern| hash[:verb]="list" hash[:pattern]=pattern return hash end opts.on('-i','--import','import remotes') do |import| hash[:verb]="import" return hash end opts.on('-r','--rake [PATTERN]','rake [PATTERN]') do |pattern| hash[:verb]="rake" if(pattern.nil?) hash[:pattern] = '' else hash[:pattern]=pattern end return hash end opts.on('-w','--work [PATTERN]','work [PATTERN]') do |pattern| hash[:verb]="work" if(pattern.nil?) hash[:pattern] = '' else hash[:pattern]=pattern end return hash end opts.on('-h','--help','help') do puts opts exit end end opt_parser.parse!() hash end |