Class: Fronde::CLI::App

Inherits:
Object
  • Object
show all
Includes:
Commands
Defined in:
lib/fronde/cli.rb

Overview

Fronde CLI app

Instance Method Summary collapse

Methods included from Commands

#fronde_build, #fronde_help, #fronde_new, #fronde_open, #fronde_preview, #fronde_publish, #fronde_update

Constructor Details

#initialize(opts = {}) ⇒ App

Returns a new instance of App.



10
11
12
13
14
# File 'lib/fronde/cli.rb', line 10

def initialize(opts = {})
  @options = { verbose: false }.merge(opts)
  @command = @rake = nil
  @argv = []
end

Instance Method Details

#run(argv) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fronde/cli.rb', line 18

def run(argv)
  @argv = argv
  @command = OptParse.resolve_possible_alias(@argv.shift || 'basic')

  if help_param_given?
    return 2 if @options[:recover_from_error]

    return true
  end

  init_rake if %w[build preview publish].include?(@command)

  method = :"fronde_#{@command}"
  return 2 if method_unknown?(method)

  send method
end