#!/usr/bin/env ruby # frozen_string_literal: true require 'optparse' require_relative '../lib/ansible_doc_generator' options = { lang: 'en' } option_parser = OptionParser.new do |opts| opts.banner = 'Usage: ansible-doc-generator [options]' opts.on("-p playbook_path", "--playbook=playbook_path", String, "Path to the playbook") do |playbook| options[:playbook] = playbook end opts.on("-l es|en", "--lang=es|en", String, "Documentation language (default en)") do |lang| options[:lang] = lang end opts.on('-h', '--help', 'Show this message') do puts opts exit end end begin option_parser.parse! rescue OptionParser::ParseError => e warn e.message.capitalize warn 'Type "ansible_doc_generator -h" for available options' exit end abort(option_parser.help) if options[:playbook].nil? # Run generator AnsibleDocGenerator::DocGenerator.new(options[:playbook], options[:lang]).call