Class: Xnlogic::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/xnlogic/cli.rb

Defined Under Namespace

Classes: Application, Core, Deploy

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



16
17
18
19
20
21
22
23
24
# File 'lib/xnlogic/cli.rb', line 16

def initialize(*args)
  super
rescue UnknownArgumentError => e
  raise InvalidOption, e.message
ensure
  self.options ||= {}
  Xnlogic.ui = UI::Shell.new(options)
  Xnlogic.ui.level = "debug" if options["verbose"]
end

Class Method Details

.handle_no_command_error(command, has_namespace = $thor_runner) ⇒ Object



53
54
55
56
# File 'lib/xnlogic/cli.rb', line 53

def self.handle_no_command_error(command, has_namespace = $thor_runner)
  return super unless command_path = Xnlogic.which("xnlogic-#{command}")
  Kernel.exec(command_path, *ARGV[1..-1])
end

.source_rootObject



175
176
177
# File 'lib/xnlogic/cli.rb', line 175

def self.source_root
  File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

.startObject



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

def self.start(*)
  super
rescue Exception => e
  Xnlogic.ui = UI::Shell.new
  raise e
end

.vm_config_optionsObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/xnlogic/cli.rb', line 59

def self.vm_config_options
  method_option "key", type: :string, banner:
    "You must supply an XN key to be able to download the proprietary dependencies needed to boot your application"
  method_option "cpus", type: :numeric, banner:
    "Number of Virtual CPUs the Development VM should use (default 2)"
  method_option "memory", type: :numeric, banner:
    "Amount of RAM to allow the Development VM to use (default 2048, in MB)"
  method_option "root", type: :string, banner:
    "Optionally specify a different root directory name"
  method_option "provision", type: :boolean, banner:
    "Update the VM with the new provisioning settings"
  method_option "up", type: :boolean, banner:
    "Start the the VM (will provision automatically only on the first run)"
  method_option "datomic_version", type: :string, banner:
    "Optionally specify the desired Datomic version number"
  method_option "datomic_pro", type: :boolean, banner:
    "Use pacer-mcfly-pro instead of pacer-mcfly-free"
  method_option "datomic_mysql", type: :boolean, banner:
    "Add pacer-mcfly-mysql dependency. Implies datomic-pro."
  method_option "datomic_username", type: :string, banner:
    "Your my.datomic.com account username, needed for Datomic jar downloads"
  method_option "datomic_key", type: :string, banner:
    "Your my.datomic.com download key, needed for Datomic jar downloads"
  method_option "datomic_license", type: :string, banner:
    "File location of your my.datomic.com license key, needed for the Datomic Pro transactor"
end

Instance Method Details

#application(name = nil) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/xnlogic/cli.rb', line 96

def application(name = nil)
  app = Application.new(options, self)
  if options['same'] or name.nil?
    app.in_existing_project
  else
    app.set_name(name)
  end
  app.application
end

#destroyObject



146
147
148
# File 'lib/xnlogic/cli.rb', line 146

def destroy
  exec 'vagrant destroy'
end

#gem_sourcesObject



119
120
121
122
123
# File 'lib/xnlogic/cli.rb', line 119

def gem_sources
  app = Application.new(options, self).in_existing_project
  app.show_source "https://rubygems.org/"
  app.show_source "https://#{app.options['key']}@gems.xnlogic.com/"
end

#haltObject



141
142
143
# File 'lib/xnlogic/cli.rb', line 141

def halt
  exec 'vagrant halt'
end

#help(cli = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/xnlogic/cli.rb', line 35

def help(cli = nil)
  case cli
  when nil       then command = "xnlogic"
  else                command = "xnlogic-#{cli}"
  end
  manpages = %w(xnlogic)
  if manpages.include?(command)
    root = File.expand_path("../man", __FILE__)
    if Xnlogic.which("man") && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
      Kernel.exec "man #{root}/#{command}"
    else
      puts File.read("#{root}/#{command}.txt")
    end
  else
    super
  end
end

#key(xn_key) ⇒ Object



151
152
153
154
# File 'lib/xnlogic/cli.rb', line 151

def key(xn_key)
  app = Application.new(options, self)
  app.update_key(xn_key)
end

#provisionObject



131
132
133
# File 'lib/xnlogic/cli.rb', line 131

def provision
  system 'vagrant provision'
end

#server_profile(hostname) ⇒ Object



164
165
166
167
# File 'lib/xnlogic/cli.rb', line 164

def server_profile(hostname)
  app = Deploy.new(options, self)
  app.server_profile(hostname)
end

#sshObject



136
137
138
# File 'lib/xnlogic/cli.rb', line 136

def ssh
  exec 'vagrant ssh'
end

#upObject



126
127
128
# File 'lib/xnlogic/cli.rb', line 126

def up
  system 'vagrant up'
end

#versionObject



170
171
172
# File 'lib/xnlogic/cli.rb', line 170

def version
  puts(Xnlogic::VERSION)
end

#vm_configObject



110
111
112
# File 'lib/xnlogic/cli.rb', line 110

def vm_config
  Application.new(options, self).in_existing_project.vm_config
end