Mercurial > dotfiles.old
view bin/mkreport @ 215:ffe47a1b75f8
Add Scratch plugin and lazyload some plugins
author | zegervdv <zegervdv@me.com> |
---|---|
date | Fri, 05 Dec 2014 23:06:30 +0100 |
parents | 016c657f0c31 |
children |
line wrap: on
line source
#!/usr/bin/env ruby # 2014, Zeger Van de Vannet # # mkreport: Create a new latex report from template require 'optparse' require 'ostruct' require 'erb' TEMPLATE_DIR = File.expand_path(".templates", "~") LANGS = { "nl" => 'dutch', "en" => 'english' } options = OpenStruct.new # defaults options.title = "TITLE HERE" options.lang = "english" options.class_opts = ["a4paper"] OptionParser.new do |opts| opts.banner = "Usage: mkreport [options] [filename]" opts.on('-t', '--title TITLE', 'Set the title') { |opt| options.title = opt } opts.on('-l','--language LANG', 'Set the language' ) { |opt| options.lang = LANGS[opt] || options.lang } opts.on('--toc', 'Add Table of contents') { |opt| options.toc = true } opts.on('-v', '--verbose', 'Show more (debugging) information') { |opt| options.verbose = true } opts.on('--titlepage', 'Set a title page') { |opt| options.class_opts << 'titlepage' } end.parse! if ARGV.empty? options.filename = 'report.tex' else options.filename = "#{ARGV.first}.tex" end puts options.inspect if options.verbose template = File.read(File.expand_path('report.tex.erb', TEMPLATE_DIR)) File.open(options.filename, 'w') do |report| @options = options report.puts ERB.new(template).result() puts "Created #{options.filename}" end