Skip to content

Commit

Permalink
Rename generate_issue_template_urls and take only one arg
Browse files Browse the repository at this point in the history
  • Loading branch information
jawshooah committed Oct 12, 2016
1 parent 8e55863 commit 0d60d8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
#
# generate_issue_template_urls
# generate_issue_template_url
#

###
Expand All @@ -20,11 +20,8 @@ BASE_URL = "https://github.com/caskroom/homebrew-cask/issues/new".freeze
###

def main(args)
args.each do |file|
File.read(file).scan(%r{(.*?)\n(.*)}m) do |title, body|
puts generate_url(title, body)
end
end
title, body = File.read(args[0]).match(%r{(.*?)\n(.*)}m).captures
print generate_url(title, body)
end

def generate_url(title, body)
Expand All @@ -46,11 +43,10 @@ end
###

usage = <<-EOS
Usage: generate_issue_template_urls <issue_template.md> ...
Usage: generate_issue_template_url <issue_template.md>
Given one or more GitHub issue template files, generate encoded URLs for each
and print, separated by newlines. The first line of a template file should be
the issue title.
Print an encoded URL for the given GitHub issue template. The first line of
a template file should be the issue title.
With -debug, print out the encoded title and body individually as well.
Expand All @@ -66,7 +62,7 @@ if ARGV.first =~ %r{^-+debug?$}i
ARGV.shift
end

if ARGV.empty?
if ARGV.size != 1
puts usage
exit 1
end
Expand Down
6 changes: 3 additions & 3 deletions developer/bin/update_issue_template_urls
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ shopt -s nocasematch # case-insensitive regular expressions

script_subdir='developer/bin'
template_subdir='doc/issue_templates'
generate_url_script='generate_issue_template_urls'
files_to_update=('README.md')
generate_url_script='generate_issue_template_url'
files_to_update=(README.md doc/readme.md doc/reporting_bugs/*)

###
### functions
Expand Down Expand Up @@ -77,7 +77,7 @@ update_template_url () {
local escaped_template_url="${template_url/&/\\&}"

/usr/bin/sed -i '' \
-e "s|^\\(\\[${template_name}_template\\]: \\).*$|\\1${escaped_template_url}|g" \
-e "s|^\\(\\[${template_name}\\]: \\).*$|\\1${escaped_template_url}|g" \
-- "${files_to_update[@]}"
}

Expand Down

0 comments on commit 0d60d8f

Please sign in to comment.