45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/ccfg/handler.rb', line 45
def handler ( global_options, args )
if args.size == 0 then
puts "Error: to few arguments for command."
exit
end
input = args[0]
args.delete_at(0)
cconfigure_definition_list = {}
args.each do |a|
keyval = []
if a.include? '=' then
keyval = a.split('=')
else
keyval << a
keyval << ""
end
cconfigure_definition_list[keyval[0]] = keyval[1]
end
if global_options[:output].value != nil then
fout = File.new( global_options[:output].value, 'w' )
end
File.open( input, 'r' ).readlines.each do |line|
line = parse_line line, cconfigure_definition_list
if global_options[:output].value != nil
fout.puts line
else
puts line
end
end
if global_options[:output].value != nil then
fout.close
end
end
|