From: "ara.t.howard" Date: 2007-12-21T05:18:44+09:00 Subject: Re: OptionParser Question On Dec 20, 2007, at 12:26 PM, Bryan Richardson wrote: > Hello all, > > I'm using OptionParser to parse command line options. I've figured > out how > to handle options for each flag (i.e. opts.on('--port PORT')), but > I'm not > sure how to handle command line arguments that aren't associated > with a > flag. For example, say I wanted to parse a file with my file_parser > executable using a certain type of parser. I'd like to say > "file_parser > --type CDF ". I know how to get the type of parser to > use (see > above), but I'm not so sure how to easily get the name of the file > I want to > parse. > > Any suggestions? Thanks! -- BTR don't bother: 1) gem install main 2) cat a.rb #! /usr/bin/env ruby Main { argument('file_name'){} option('type'){ argument :required } def run p params['file_name'].given? p params['file_name'] p params['type'].given? p params['type'] end } a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama