Class: Landrush::Command
- Inherits:
-
Object
- Object
- Landrush::Command
- Defined in:
- lib/landrush/command.rb
Constant Summary collapse
- DAEMON_COMMANDS =
%w(start stop restart status).freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.synopsis ⇒ Object
5 6 7 |
# File 'lib/landrush/command.rb', line 5 def self.synopsis 'manages DNS for both guest and host' end |
Instance Method Details
#boom(msg) ⇒ Object
36 37 38 |
# File 'lib/landrush/command.rb', line 36 def boom(msg) raise Vagrant::Errors::CLIInvalidOptions, help: usage(msg) end |
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/landrush/command.rb', line 9 def execute # Make sure we use the right data directory for Landrush Server.working_dir = File.join(@env.data_dir, 'landrush') Server.gems_dir = File.join(@env.gems_path, 'gems') Server.ui = @env.ui ARGV.shift # flush landrush from ARGV command = ARGV.first || 'help' if DAEMON_COMMANDS.include?(command) Server.send(command) elsif command == 'dependentvms' || command == 'vms' dependent_vms elsif command == 'ls' || command == 'list' store_ls elsif command == 'set' store_set elsif command == 'del' || command == 'rm' store_del elsif command == 'help' @env.ui.info(help) else boom("'#{command}' is not a command") end 0 # happy exit code end |
#help ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/landrush/command.rb', line 47 def help; <<-EOS.gsub(/^ /, '') vagrant landrush <command> commands: {start|stop|restart|status} control the landrush server daemon list, ls list all DNS entries known to landrush dependentvms, vms list vms currently dependent on the landrush server set { <host> <ip> | <alias> <host> } adds the given host-to-ip or alias-to-hostname mapping. Existing host ip addresses will be overwritten rm, del { <host> | <alias> | --all } delete the given hostname or alias from the server. --all removes all entries help you're lookin at it! EOS end |
#usage(msg) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/landrush/command.rb', line 40 def usage(msg); <<-EOS.gsub(/^ /, '') ERROR: #{msg} #{help} EOS end |