2009/1/20 Foreero Ivan <ivmafo / gmail.com>: > Hola, me gustaria saber si existe alguna forma de generar mis propios > argumentos en una linea de comando . Algo asi como como se usa el ARGV: > > $ ruby miscript.rb --miargumento1=1 --miargumento2=2 .... > > para poder usar las variables "miargumentoX" dentro de mi script ruby > > Gracias de antemano.... Hola. En Ruby existe un objeto llamado precisamente ARGV que es un array que contiene los argumentos del programa: jesus@jesus-laptop:~/temp/ruby$ ruby argv.rb --miargumento1=2 --miargumento2=3 ["--miargumento1=2", "--miargumento2=3"] jesus@jesus-laptop:~/temp/ruby$ cat argv.rb p ARGV Para facilitar un procesamiento máÔ complejo, echale un vistazo a OptionParser, GetOptLong y gemas como main o trollop, que te ayudan a procesar opciones pasadas como argumentos. Por ejemplo, este es un trozo de un script mùÐ usando la gema main require 'main' main { description <<-DESC Deletes or gzips jhub log files older than the specified dates, searching the specified directories recursively. The files should match this regexp /^(\d\d\d\d-\d\d-\d\d).*\.log(\.gz)?$/ DESC option("zip", "z") { argument :required description "Zip files older than the specified number of days" cast :int } option("delete", "d") { argument :required defaults 7 description "Delete files older than the specified number of days. If --zip option is specified, only delete the files that are in between both dates" cast :int } argument("directories") { arity -2 } def run folders = params[:directories].values have_to_zip = params[:zip].given? zip = params[:zip].value # Resto del programa # ... } Jesus.