def parse_options(argv)
      params = OpenStruct.new
      parser = OptionParser.new

      parser.banner = 'Usage: filegen [options] <template>'

      parser.separator ''
      parser.separator 'Specific options:'

      params.data_sources = [:env]
      params.data_source_builders = {}
      params.data_source_builders[:env]  = DataSources::Environment.new

      parser.on('-y', '--yaml-file FILE', 'YAML-file to look for variables') do |f|
        params.yaml_file = f
        params.data_sources << :yaml
        params.data_source_builders[:yaml] = DataSources::Yaml.new(params.yaml_file)
      end

      parser.on('-d', '--data-sources a,b', Array,  'Order for variable lookup: yaml, env (default: env or env,yaml if yaml-file-option is given)') do |l|
        params.data_sources = l.map(&:to_sym)
      end

      parser.separator ''
      parser.separator 'Common options:'

      parser.on_tail('-h', '--help', 'Show this message') do
        $stderr.puts parser
        exit
      end

      parser.on_tail('-v', '--version', 'Show version') do
        $stderr.puts Filegen::VERSION
        exit
      end

      params.template = parser.parse(argv).first

      params
    end
def parse_options(argv)
      params = OpenStruct.new
      parser = OptionParser.new

      parser.banner = 'Usage: filegen [options] <template>'

      parser.separator ''
      parser.separator 'Specific options:'

      params.data_sources = [:env]
      params.data_source_builders = {}
      params.data_source_builders[:env]  = DataSources::Environment.new

      parser.on('-y', '--yaml-file FILE', 'YAML-file to look for variables') do |f|
        params.yaml_file = f
        params.data_sources << :yaml
        params.data_source_builders[:yaml] = DataSources::Yaml.new(params.yaml_file)
      end

      parser.on('-d', '--data-sources a,b', Array,  'Order for variable lookup: yaml, env (default: env or env,yaml if yaml-file-option is given)') do |l|
        params.data_sources = l.map(&:to_sym)
      end

      parser.separator ''
      parser.separator 'Common options:'

      parser.on_tail('-h', '--help', 'Show this message') do
        $stderr.puts parser
        exit
      end

      parser.on_tail('-v', '--version', 'Show version') do
        $stderr.puts Filegen::VERSION
        exit
      end

      params.template = parser.parse(argv).first

      params
    end
rubocop:disable MethodLength