Lines Matching +full:options +full:-
2 # Copyright (c) 2021-2022 Huawei Device Co., Ltd.
7 # http://www.apache.org/licenses/LICENSE-2.0
47 def check_option(optparser, options, key) argument
48 return if options[key]
50 puts "Missing option: --#{key}"
62 options = OpenStruct.new
65 opts.banner = 'Usage: gen.rb [options]'
67 opts.on('-t', '--template FILE', 'Template for file generation (required)')
68 opts.on('-d', '--data FILE', 'Source data in YAML format (required)')
69 opts.on('-o', '--output FILE', 'Output file (default is stdout)')
70 opts.on('-a', '--assert FILE', 'Go through assertions on data provided and exit')
71 opts.on('-r', '--require foo,bar,baz', Array, 'List of files to be required for generation')
73 opts.on('-h', '--help', 'Prints this help') do
78 optparser.parse!(into: options)
80 check_option(optparser, options, :data)
81 data = YAML.load_file(File.expand_path(options.data))
84 options&.require&.each { |r| require File.expand_path(r) } if options.require
87 if options.assert
88 require options.assert
92 check_option(optparser, options, :template)
93 template = File.read(File.expand_path(options.template))
94 output = options.output ? File.open(File.expand_path(options.output), 'w') : $stdout
95 t = ERB.new(template, nil, '%-')
96 t.filename = options.template