Commandline: How to add an own option?

I tried it this way, but it fails und the ducumentation is extremely
poor:

def initialize
version "0.0.1"
author "me"
copyright "2010, me"
synopsis "[-dh] log_file out_file"
short_description "A simple app example that takes two arguments."
long_description "app5 is a simple application"

option :version, :names => %w(--version -v)

# Here is my new option:
option :distance, :names => %w(--distance -d), :arity => [1,1],
   :arg_description => "Distanz",
   :opt_description => "Maximale Entfernung [m]"

option :help
expected_args :log_file, :out_file
end

What is wrong with my option distance?

···

--
Posted via http://www.ruby-forum.com/.

You need to give more context then this. What code is this? As far as
I can tell it's just a error from word 'version'.

···

On Dec 5, 6:01 pm, Fritz Trapper <ajfren...@web.de> wrote:

I tried it this way, but it fails und the ducumentation is extremely
poor:

def initialize
version "0.0.1"
author "me"
copyright "2010, me"
synopsis "[-dh] log_file out_file"
short_description "A simple app example that takes two arguments."
long_description "app5 is a simple application"

option :version, :names => %w(--version -v)

# Here is my new option:
option :distance, :names => %w(--distance -d), :arity => [1,1],
:arg_description => "Distanz",
:opt_description => "Maximale Entfernung [m]"

option :help
expected_args :log_file, :out_file
end

Ok, the simplest way to overcome problems like this is, to dicard all
that obscure CommandLine::Application bullshit and handcode commandline
handling.

···

--
Posted via http://www.ruby-forum.com/.

Thomas Sawyer wrote in post #966397:

You need to give more context then this. What code is this? As far as
I can tell it's just a error from word 'version'.

OK, the context is:

···

-------------
#!/usr/bin/env ruby
require 'rubygems'
require 'commandline'

class App < CommandLine::Application
  def initialize
    < the body from my openining >
  end
end
-------------

The code has been stolen from the rdoc of class CommandLine. The only
thing, I added to initialize was the statement

   option :distance, :names => ...

w/o this, the code works, but I need an option distance for my app.

I don't think, that the error message:
   ERROR: Unknown option setting 'distance'.
follows from the option :version, :names => %w(--version -v)

--
Posted via http://www.ruby-forum.com/\.