diff --git a/developer/bin/cask-pr-local-check b/developer/bin/cask-pr-local-check index 7a71b07b21..993b8066e7 100755 --- a/developer/bin/cask-pr-local-check +++ b/developer/bin/cask-pr-local-check @@ -1,12 +1,32 @@ #!/usr/bin/env ruby -require 'open-uri' require 'json' +require 'open-uri' +require 'optparse' require 'tmpdir' +# Options +ARGV.push('--help') if ARGV.empty? + +OptionParser.new do |opt| + opt.banner = <<~BANNER + Run `brew cask` `audi` and `style` checks locally, from a pull request URL. + Useful when online CI is broken. + + Usage: + #{File.basename($PROGRAM_NAME)} + + Options: + BANNER + + opt.on('-h', '--help', 'Show this help.') do + puts opt + exit 0 + end +end.parse! + pr_url = ARGV[0] -abort 'You need to give the script exactly one argument, the URL to a pull request from an official Homebrew Cask tap' if pr_url.nil? abort 'URL is not from an official Homebrew Cask tap' if pr_url !~ %r{^https://github.com/Homebrew/homebrew-cask.*} pr_api = pr_url.sub(%r{^https://github.com/([^/]+)/([^/]+)/pull/([^/]+).*}, 'https://api.github.com/repos/\1/\2/pulls/\3/files')