Class: MagicReveal::Cli
- Inherits:
-
Object
- Object
- MagicReveal::Cli
- Extended by:
- Forwardable
- Defined in:
- lib/magic_reveal/cli.rb,
lib/magic_reveal/cli/options.rb
Overview
Command line interface
Defined Under Namespace
Classes: Options
Instance Attribute Summary collapse
Class Method Summary collapse
-
.run(args = ARGV) ⇒ Object
Helper method.
Instance Method Summary collapse
- #avenge_programmer ⇒ Object
-
#create_static ⇒ Object
rubocop:disable MethodLength.
- #options ⇒ Object
-
#run(args = ARGV) ⇒ Object
rubocop:disable MethodLength, CyclomaticComplexity.
-
#show_help ⇒ Object
Action Classes.
- #start_server ⇒ Object
Instance Attribute Details
Class Method Details
.run(args = ARGV) ⇒ Object
Helper method
22 23 24 |
# File 'lib/magic_reveal/cli.rb', line 22 def self.run(args = ARGV) new.run args end |
Instance Method Details
#avenge_programmer ⇒ Object
76 77 78 79 80 |
# File 'lib/magic_reveal/cli.rb', line 76 def avenge_programmer puts 'The programmer messed up.' puts 'Please file a bug at https://github.com/docwhat/magic_reveal' exit 13 end |
#create_static ⇒ Object
rubocop:disable MethodLength
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/magic_reveal/cli.rb', line 58 def create_static # rubocop:disable MethodLength = Pathname.pwd + 'slides.md' markdown = SlideRenderer.markdown_renderer libber = IndexLibber.new config = ProjectConfig.new(Pathname.pwd + 'config.json') libber. = Identifier.name libber. = markdown.render .read libber.add_github_forkme config.json['github'] if config.json.key? 'github' index_html = Pathname.pwd + 'index.html' index_html.open('w') { |f| f.print libber } js_file = Pathname.pwd + 'index.js' js_file.open('w') { |f| f.print config.to_js } end |
#options ⇒ Object
82 83 84 |
# File 'lib/magic_reveal/cli.rb', line 82 def @options ||= Options.new end |
#run(args = ARGV) ⇒ Object
rubocop:disable MethodLength, CyclomaticComplexity
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/magic_reveal/cli.rb', line 86 def run(args = ARGV) # rubocop:disable MethodLength, CyclomaticComplexity .parse args case command when :new creator.create_project(project) when :force_reload theyre_sure = (ask('This may overwrite customizations. Are you sure? (y/N) ') { |q| q.limit = 1; q.case = :downcase }) == 'y' # rubocop:disable Semicolon creator.update_project(Dir.getwd) if theyre_sure when :start start_server when :static create_static when :help show_help else avenge_programmer end end |
#show_help ⇒ Object
Action Classes
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/magic_reveal/cli.rb', line 27 def show_help # rubocop:disable MethodLength puts <<-EOF Usage: #{program_name} <command> Magic reveal version: #{MagicReveal::VERSION} new <name> Creates new presentation in directory <name> force-reload Refreshes the reveal.js files. WARNING: This may override customizations! start [options] Starts serving the presentation in the current directory static Creates a static index.html file from your slides EOF exit end |
#start_server ⇒ Object
51 52 53 54 55 56 |
# File 'lib/magic_reveal/cli.rb', line 51 def start_server require 'rack' ARGV.shift Rack::Server.start exit end |