1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #1383: Fix DSL-CLI argument check for non-command based tools

This commit is contained in:
Ruben S. Montero 2012-09-27 00:04:13 +02:00
parent 4d31bfb0be
commit 4e478fc80f

View File

@ -90,6 +90,12 @@ module CommandParser
@description = str
end
# Defines the name of the command
# @param [String] str
def name(str)
@name = str
end
# Defines a block that will be used to parse the arguments
# of the command. Formats defined using this method con be used
# in the arguments section of the command method, when defining a new
@ -386,12 +392,14 @@ module CommandParser
def run
comm_name=""
if @main
comm=@main
comm_name = @name
comm = @main
elsif
if @args[0] && !@args[0].match(/^-/)
comm_name=@args.shift.to_sym
comm=@commands[comm_name]
comm_name = @args.shift.to_sym
comm = @commands[comm_name]
end
end
@ -470,8 +478,13 @@ module CommandParser
end
puts
puts "Usage:"
print " #{name} "
print_command(@commands[name])
if @main
print " #{@usage}\n"
else
print " #{name} "
print_command(@commands[name])
end
exit -1
else
id=0