lib/ctioga2/commands/parsers/command-line.rb in ctioga2-0.3 vs lib/ctioga2/commands/parsers/command-line.rb in ctioga2-0.4
- old
+ new
@@ -15,11 +15,11 @@
require 'ctioga2/log'
require 'ctioga2/commands/commands'
module CTioga2
- Version::register_svn_info('$Revision$', '$Date$')
+ Version::register_svn_info('$Revision: 327 $', '$Date: 2012-11-28 14:47:52 +0100 (Wed, 28 Nov 2012) $')
module Commands
# In this modules are classes that parse a source of commands, and
# yield to the caller the commands (Command) along with their
@@ -69,17 +69,20 @@
# specified.
def parse_command_line(argv, interpreter)
# We duplicate the original array
argv = argv.dup
options = nil # currently never used.
+ number = 0
while argv.size > 0
current = argv.shift
if current =~ /^--(.*)/ # a long option
if @long_options.key?($1)
command, arguments, options =
extract_command_arguments(argv, @long_options[$1])
+ number += 1
+ interpreter.context.parsing_option(current, number)
interpreter.run_command(command, arguments, options)
else
raise OptionUnkown, "Long option #{current} is not known"
end
elsif current =~ /^-(.*)/ # Short options
@@ -87,19 +90,23 @@
short_options = $1.split('')
for short in short_options
if @short_options.key?(short)
command, arguments, options =
extract_command_arguments(argv, @short_options[short])
+ number += 1
+ interpreter.context.parsing_option("-#{short}", number)
interpreter.run_command(command, arguments, options)
else
raise OptionUnkown, "Short option -#{short} is not known"
end
end
else
if @default_command
argv.unshift current
command, arguments, options =
extract_command_arguments(argv, @default_command)
+ number += 1
+ interpreter.context.parsing_option("(default)", number)
interpreter.run_command(command, arguments, options)
else
yield current
end
end