Sha256: 343753b74690e6cb572e48f65c727f083d767fb5ed4d18a96ac68203d394d179

Contents?: true

Size: 639 Bytes

Versions: 3

Compression:

Stored size: 639 Bytes

Contents

module Spigoter
	module CLI
		def self.start(opts)
			unless which('java').nil?
				Log.info "Starting the server!"
				system("java #{opts[:javaparm]}")
			else
				Log.error "You don't have java in PATH"
			end
		end

		def self.which(cmd)
			# http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
			exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
			ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
				exts.each { |ext|
					exe = File.join(path, "#{cmd}#{ext}")
					return exe if File.executable?(exe) && !File.directory?(exe)
				}
			end
			return nil
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spigoter-0.2.2 lib/spigoter/cli/cli_start.rb
spigoter-0.2.0 lib/spigoter/cli/cli_start.rb
spigoter-0.1.2 lib/spigoter/cli/cli_start.rb