Class: Xnlogic::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/xnlogic/cli.rb
Defined Under Namespace
Classes: Application, Core, Deploy
Class Method Summary collapse
- .handle_no_command_error(command, has_namespace = $thor_runner) ⇒ Object
- .source_root ⇒ Object
- .start ⇒ Object
- .vm_config_options ⇒ Object
Instance Method Summary collapse
- #application(name = nil) ⇒ Object
- #gem_sources ⇒ Object
- #help(cli = nil) ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #key(xn_key) ⇒ Object
- #provision ⇒ Object
- #server_profile(hostname) ⇒ Object
- #ssh ⇒ Object
- #up ⇒ Object
- #version ⇒ Object
- #vm_config ⇒ Object
Constructor Details
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_root ⇒ Object
153 154 155 |
# File 'lib/xnlogic/cli.rb', line 153 def self.source_root File.(File.join(File.dirname(__FILE__), 'templates')) end |
.start ⇒ Object
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_options ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/xnlogic/cli.rb', line 59 def self. 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)" end |
Instance Method Details
#application(name = nil) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/xnlogic/cli.rb', line 84 def application(name = nil) app = Application.new(, self) if ['same'] or name.nil? app.in_existing_project else app.set_name(name) end app.application end |
#gem_sources ⇒ Object
107 108 109 110 111 |
# File 'lib/xnlogic/cli.rb', line 107 def gem_sources app = Application.new(, self).in_existing_project app.show_source "https://rubygems.org/" app.show_source "https://#{app.['key']}@gems.xnlogic.com/" 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.("../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
129 130 131 132 |
# File 'lib/xnlogic/cli.rb', line 129 def key(xn_key) app = Application.new(, self) app.update_key(xn_key) end |
#provision ⇒ Object
119 120 121 |
# File 'lib/xnlogic/cli.rb', line 119 def provision system 'vagrant provision' end |
#server_profile(hostname) ⇒ Object
142 143 144 145 |
# File 'lib/xnlogic/cli.rb', line 142 def server_profile(hostname) app = Deploy.new(, self) app.server_profile(hostname) end |
#ssh ⇒ Object
124 125 126 |
# File 'lib/xnlogic/cli.rb', line 124 def ssh exec 'vagrant ssh' end |
#up ⇒ Object
114 115 116 |
# File 'lib/xnlogic/cli.rb', line 114 def up system 'vagrant up' end |
#version ⇒ Object
148 149 150 |
# File 'lib/xnlogic/cli.rb', line 148 def version puts(Xnlogic::VERSION) end |
#vm_config ⇒ Object
98 99 100 |
# File 'lib/xnlogic/cli.rb', line 98 def vm_config Application.new(, self).in_existing_project.vm_config end |