1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

bug #2780: fix --csv flag for CLI in ruby 1.8.7

This commit is contained in:
Javi Fontan 2014-03-18 16:23:40 +01:00
parent 46d423d993
commit 6b24eb51e1
2 changed files with 5 additions and 7 deletions

View File

@ -25,7 +25,7 @@ module CLIHelper
:description => "Selects columns to display with list command"
}
CSV = {
CSV_OPT = {
:name => "csv",
:large => "--csv",
:description => "Write table in csv format"
@ -64,7 +64,7 @@ module CLIHelper
}
#OPTIONS = [LIST, ORDER, FILTER, HEADER, DELAY]
OPTIONS = [LIST, DELAY, FILTER, CSV]
OPTIONS = [LIST, DELAY, FILTER, CSV_OPT]
# Sets bold font
def CLIHelper.scr_bold
@ -268,10 +268,8 @@ module CLIHelper
begin
if options[:csv]
CSV($stdout, :write_headers => true,
:headers => @default_columns) do |csv|
res_data.each {|l| csv << l }
end
puts CSV.generate_line(@default_columns)
res_data.each {|l| puts CSV.generate_line(l) }
else
res_data.each{|l|
puts (0..ncolumns-1).collect{ |i|

View File

@ -44,7 +44,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do
end
option AcctHelper::ACCT_OPTIONS + CommandParser::OPTIONS +
[OpenNebulaHelper::DESCRIBE, CLIHelper::LIST, CLIHelper::CSV] +
[OpenNebulaHelper::DESCRIBE, CLIHelper::LIST, CLIHelper::CSV_OPT] +
OpenNebulaHelper::CLIENT_OPTIONS
main do