class Appfront::Command::Base
Protected Class Methods
ask()
click to toggle source
# File lib/appfront/command/base.rb, line 35 def self.ask $stdin.gets.to_s.strip end
echo_off()
click to toggle source
# File lib/appfront/command/base.rb, line 18 def self.echo_off with_tty do system "stty -echo" end end
echo_on()
click to toggle source
# File lib/appfront/command/base.rb, line 24 def self.echo_on with_tty do system "stty echo" end end
find_deploy!(opts)
click to toggle source
# File lib/appfront/command/base.rb, line 39 def self.find_deploy!(opts) if opts[:deploy] @deploy = opts[:deploy] end return true if @deploy puts 'No deploy specified.' puts 'Specify which deploy to use with --deploy DEPLOY.' exit 1 end
spinner(desc, &block)
click to toggle source
# File lib/appfront/command/base.rb, line 62 def self.spinner(desc, &block) chars = %w{ | / - \\ } t = Thread.new { block.call } while t.alive? print "#{desc} [#{chars[0]}]\t" sleep 0.1 print "\r" chars.push chars.shift end t.join print "#{desc} [ok] \t" end
which(cmd)
click to toggle source
# File lib/appfront/command/base.rb, line 51 def self.which(cmd) 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 } end return nil end
with_tty() { || ... }
click to toggle source
# File lib/appfront/command/base.rb, line 30 def self.with_tty(&block) return unless $stdin.isatty yield end