Sha256: 86a61d15a31ab6e7589b4225efa4ef2ceb17d9439ca4a407cb6791e3ed1b9bd0
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# don't require the approvals library here, as it will reset the dotfile. # or find a better way to reset the dotfile before a run. module Approvals class CLI < Thor desc "verify", "Go through all failing approvals with a diff tool" method_option :diff, :type => :string, :default => 'diff -N', :aliases => '-d', :desc => 'The difftool to use. e.g. opendiff, vimdiff, etc.' method_option :ask, :type => :boolean, :default => true, :aliases => "-a", :desc => 'Offer to approve the received file for you.' def verify approvals = File.read('.approvals').split("\n") rejected = [] approvals.each do |approval| diff_command = "#{options[:diff]} #{approval}" puts diff_command system(diff_command) if options[:ask] && yes?("Approve? [y/N] ") approved, received = *approval.split system("mv #{received} #{approved}") else rejected << approval end end File.open('.approvals', 'w') do |f| f.write rejected.join("\n") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
approvals-0.0.18 | lib/approvals/cli.rb |