From 021587d453060a34e839d0f2dbcd4fe2d8f14f04 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 14 Jun 2011 17:34:35 +0200 Subject: [PATCH] feature #661: Add default format --- src/authm_mad/oneauth | 2 +- src/cli/command_parser.rb | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/authm_mad/oneauth b/src/authm_mad/oneauth index 73bcb695ca..f729d356c9 100755 --- a/src/authm_mad/oneauth +++ b/src/authm_mad/oneauth @@ -74,7 +74,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do Sets CPU, MEMORY and NUM_VMs quota for a given user EOT - command 'quota-set', quotaset_desc , :userid, :text, :text, :text do + command 'quota-set', quotaset_desc , :userid, :cpu, :memory, :num_vms do Dir.chdir VAR_LOCATION begin add_quota(*args[1..4]) diff --git a/src/cli/command_parser.rb b/src/cli/command_parser.rb index 03f75fbdb6..cf9516da51 100755 --- a/src/cli/command_parser.rb +++ b/src/cli/command_parser.rb @@ -160,7 +160,7 @@ module CommandParser begin rc = comm[:proc].call rescue Exception =>e - puts e.message + #puts e.message exit -1 end @@ -340,20 +340,14 @@ module CommandParser argument = nil error_msg = nil format.each { |f| - if @formats[f] - rc = @formats[f][:proc].call(arg) - if rc[0]==0 - argument=rc[1] - break - else - error_msg=rc[1] - next - end + format_hash = @formats[f] ? @formats[f] : @formats[:text] + rc = format_hash[:proc].call(arg) + if rc[0]==0 + argument=rc[1] + break else - puts "<#{f}> is not an aceptted format." - puts "Change your command specification or add " << - "a new formatter" - exit -1 + error_msg=rc[1] + next end }