#!/usr/bin/env ruby # frozen_string_literal: true require 'pathname' require 'yaml' require 'optparse' require 'jekyll-indico/cache' options = { config: '_config.yml' } OptionParser.new do |opts| opts.on('-c', '--config=FILE', 'Read a config file') do |c| options[:config] = c end end.parse! puts "Reading #{options[:config]}" config = YAML.safe_load(File.read(options[:config])) meeting_ids = config.dig('indico', 'ids') base_url = config.dig('indico', 'url') data_path = config.dig('indico', 'data') || 'indico' raise MissingURL, 'indico: url: MISSING from your config!' unless base_url raise MissingIDs, 'indico: ids: MISSING from your config!' unless meeting_ids raise MissingIDs, 'indico: ids: must be a hash!' unless meeting_ids.is_a?(Hash) JekyllIndico.cache(base_url, meeting_ids, data_path) do |name, number| puts "Accessing #{number} for #{name}" end