class GitSleep::Cli
Public Class Methods
start()
click to toggle source
# File lib/git-sleep/cli.rb, line 5 def self.start if command = ARGV.first command = command.to_sym end new.start(command) end
Public Instance Methods
start(command)
click to toggle source
# File lib/git-sleep/cli.rb, line 12 def start(command) case command when :init then init! when :authorize then authorize! when :'-v' then version! else send_help! end end
Private Instance Methods
auth()
click to toggle source
# File lib/git-sleep/cli.rb, line 51 def auth GitSleep::Authorizer.instance end
current_path()
click to toggle source
# File lib/git-sleep/cli.rb, line 59 def current_path File.expand_path('.') end
help_text()
click to toggle source
# File lib/git-sleep/cli.rb, line 55 def help_text "Available commands:\n git sleep authorize\n git sleep init" end
init!()
click to toggle source
# File lib/git-sleep/cli.rb, line 35 def init! raise NotGitRepoError unless Dir.entries(current_path).include?('.git') puts 'Install the pre-commit hook that prevents commits when you' \ " haven't slept enough?" HookInstaller.install('pre-commit') if user_consents? puts 'Install the post-commit hook that adds git notes about your sleep' \ ' data?' HookInstaller.install('post-commit') if user_consents? end
send_help!()
click to toggle source
# File lib/git-sleep/cli.rb, line 47 def send_help! puts help_text end
user_consents?()
click to toggle source
# File lib/git-sleep/cli.rb, line 63 def user_consents? print 'Is it okay? [y/n] ' $stdin.gets.chomp == 'y' end
version!()
click to toggle source
# File lib/git-sleep/cli.rb, line 24 def version! puts "Git Sleep v#{GitSleep::VERSION}" end