Sha256: a8044f7012750458b9e7987701bea9c6c970654bda350be3196e50159b8a67b1
Contents?: true
Size: 1.64 KB
Versions: 5
Compression:
Stored size: 1.64 KB
Contents
#!/usr/bin/env ruby require 'gli' require 'bookingit' include GLI::App include FileUtils program_desc 'Manage a bookingit book' version Bookingit::VERSION desc 'Set up a new book' arg_name 'dir (defaults to .)' command :init do |c| c.action do |global_options,options,args| dir = args.shift || "." chdir dir do File.open('config.json','w') do |file| file.puts %{ { "front_matter": "front.md", "main_matter": "main.md", "back_matter": "back.md" } } end File.open("front.md",'w') do |file| file.puts "# Intro Goes Here" end File.open("main.md",'w') do |file| file.puts "# Main stuff here" end File.open("back.md",'w') do |file| file.puts "# Appendeces and whatnot" end end end end desc 'build your book from markdown files' arg_name '[output_dir]' command :build do |c| c.desc "Use cache for code samples and console sessions" c.default_value true c.switch :cache c.action do |global_options,options,args| config = Bookingit::Config.new(File.read('config.json'),File.expand_path('.')) config.cache = options[:cache] book = Bookingit::Book.new(config,args.shift) book.render_html! end end pre do |global,command,options,args| true end post do |global,command,options,args| end on_error do |exception| case exception when Bookingit::UnexpectedShellCommandExit $stderr.puts "'#{exception.command}' exited in an unexpected way with exit status #{exception.exit_code}" $stderr.puts "stdout:" $stderr.puts exception.stdout $stderr.puts "stderr:" $stderr.puts exception.stderr false else true end end exit run(ARGV)
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
bookingit-0.5.0 | bin/bookingit |
bookingit-0.4.1 | bin/bookingit |
bookingit-0.4.0 | bin/bookingit |
bookingit-0.3.0 | bin/bookingit |
bookingit-0.2.0 | bin/bookingit |