Sha256: 3721a35629ea69c4a9152408e2461a473b65fdf617b06e259829294b51b9a162

Contents?: true

Size: 951 Bytes

Versions: 11

Compression:

Stored size: 951 Bytes

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', :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|
        system("#{options[:diff]} #{approval}")

        if options[:ask] && yes?("Approve? [y/N] ")
          system("mv #{approval}")
        else
          rejected << approval
        end
      end

      File.open('.approvals', 'w') do |f|
        f.write rejected.join("\n")
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
approvals-0.0.17 lib/approvals/cli.rb
approvals-0.0.16 lib/approvals/cli.rb
approvals-0.0.15 lib/commandline.rb
approvals-0.0.14 lib/commandline.rb
approvals-0.0.13 lib/cli.rb
approvals-0.0.12 lib/approvals/utilities/cli.rb
approvals-0.0.11 lib/approvals/utilities/cli.rb
approvals-0.0.10 lib/approvals/utilities/cli.rb
approvals-0.0.9 lib/approvals/utilities/cli.rb
approvals-0.0.8 lib/approvals/utilities/cli.rb
approvals-0.0.7 lib/approvals/utilities/cli.rb