99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/autoproj/shell_completion.rb', line 99
def render_subcommand_function(subcommand, options = {})
prefix = options[:prefix] || []
source = []
prefix = (prefix + [subcommand[:name]])
function_name = prefix.join("_")
depth = prefix.size + 1
template_file = File.join(TEMPLATES_DIR, self.class::SUBCOMMAND_FUNCTION_TEMPLATE)
erb = ::ERB.new(File.read(template_file), nil, "-")
source << erb.result(binding)
subcommand[:subcommands].each do |subcommand|
source << render_subcommand_function(subcommand, prefix: prefix)
end
"#{source.join("\n").strip}\n"
end
|