#!/usr/bin/env ruby require 'rubygems' require 'gli' require "slideoff" include GLI::App version "0.3.5" # Slideoff::VERSION desc 'Create new slideoff presentation' arg_name 'dir_name' long_desc 'This command helps start a new slideoff presentation by setting up the proper directory structure for you. It takes the directory name you would like slideoff to create for you.' command [:init] do |c| c.action do |global_options,options,args| raise "dir_name is required" if args.empty? Slideoff::Utils.init_directory(args[0]) puts "Done. Run 'slideoff serve' in #{args[0]}/ dir to see slideshow" end end desc 'Install new slideoff theme' arg_name 'repository_url' long_desc 'Installs theme under ~/.slideoff.' command [:install_theme] do |c| c.action do |global_options,options,args| raise "repository_url is required" if args.empty? Slideoff::Utils.install_theme(args[0]) puts "Done." end end desc 'Puts your slideoff presentation into a gh-pages branch' long_desc 'Generates a static version of your presentation into your gh-pages branch for publishing to GitHub Pages' command :upload do |c| c.desc 'Port on which to run' c.default_value Slideoff::Server::DEFAULT_PORT c.flag [:p,:port] c.action do |global_options,options,args| puts "Generating static content" Slideoff::Utils.upload(options) puts "Uploaded!" end end desc 'Serves the slideoff presentation in the current directory' command :serve do |c| c.desc 'Show verbose messaging' c.switch :verbose c.desc 'Port on which to run' c.default_value Slideoff::Server::DEFAULT_PORT c.flag [:p,:port] c.desc 'Host or ip to run on' c.default_value Slideoff::Server::DEFAULT_ADDRESS c.flag [:h,:host] c.desc 'API key for remote access' c.flag [:remote_key] c.action do |global_options,options,args| server = Slideoff::Server.new(options) puts "Your remote key is #{server.remote_key}\n\n" server.start end end desc 'Generate static version of presentation' long_desc 'Creates a static version of the presentation in "static" directory' command [:static] do |c| c.desc 'Port on which to run' c.default_value Slideoff::Server::DEFAULT_PORT c.flag [:p,:port] c.action do |global_options,options,args| Slideoff::Utils.generate_static(options) end end desc 'Serves static version of presentation' long_desc 'Serves static version of presentation' command [:serve_static] do |c| c.desc 'Port on which to run' c.default_value "4242" c.flag [:p,:port] c.action do |global_options,options,args| if File.basename(Dir.pwd) =~ /^static/ Slideoff::Utils.serve_static(options[:port], verbose: true) else Dir.chdir(Slideoff::Utils.static_dir) do |dir| Slideoff::Utils.serve_static(options[:port], verbose: true) end end end end pre do |global,command,options,args| # Pre logic here # Return true to proceed; false to abourt and not call the # chosen command true end post do |global,command,options,args| # Post logic here end on_error do |exception| # Error logic here # return false to skip default error handling true end exit run(ARGV)