Class: Xmvc::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/xmvc/cli.rb

Constant Summary collapse

ARGV =
::ARGV.dup

Instance Method Summary collapse

Constructor Details

#initialize(args = ARGV, config = {}, options = {}) ⇒ CLI

Returns a new instance of CLI.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/xmvc/cli.rb', line 44

def initialize(args=ARGV, config={}, options={})
  
  # Boot UI
  Xmvc.ui = UI::Shell.new(shell)
  
  host = config.delete(:host) || options.delete(:host)
  unless host
    raise Xmvc::NoFramework.new("Xmvc is meant to be supplied with a framework extension, eg extjs-mvc, via Xmvc::CLI.start(ARGV, {:framework => Your::Framework})")
  end
  
  # Set the framework.
  Xmvc.host = host
  options.delete(:shell)
  
  # New Vendors replaces host above
  Xmvc.vendors = options.delete(:vendors)
  
  Xmvc::Config.setup(options)    
  Xmvc.config = Xmvc::Config
  Xmvc.environment = Xmvc::Config[:environment]
  
  super
end

Instance Method Details

#build(name = :all, *params) ⇒ Object



19
20
21
22
23
24
# File 'lib/xmvc/cli.rb', line 19

def build(name = :all, *params)
  Xmvc.ensure_in_app
  builder = Xmvc::Builder.new([], options.dup)
  builder.invoke(name.to_sym, params)
  #Xmvc::BuilderManager.dispatch(name, *params)
end

#generate(*params) ⇒ Object



11
12
13
14
15
16
# File 'lib/xmvc/cli.rb', line 11

def generate(*params)
  which = params.shift
  Xmvc.ensure_in_app unless which == 'app'
  Xmvc::Generator.dispatch(which, options, *params) 
  Xmvc::Config.render
end

#namespace(name) ⇒ Object



39
40
41
42
# File 'lib/xmvc/cli.rb', line 39

def namespace(name)
  Xmvc.ensure_in_app
  Xmvc::Generator.dispatch("namespace", name)
end

#pluginObject



27
28
29
30
# File 'lib/xmvc/cli.rb', line 27

def plugin
  Xmvc.ensure_in_app
  Xmvc::Plugin.new('Frak')
end

#statsObject



33
34
35
36
# File 'lib/xmvc/cli.rb', line 33

def stats
  Xmvc.ensure_in_app
  Xmvc::Stats.dispatch
end