lib/howzit/buildnote.rb in howzit-2.0.14 vs lib/howzit/buildnote.rb in howzit-2.0.15
- old
+ new
@@ -30,10 +30,15 @@
end
read_help(file)
end
+ ##
+ ## Inspect
+ ##
+ ## @return description
+ ##
def inspect
puts "#<Howzit::BuildNote @topics=[#{@topics.count}]>"
end
##
@@ -53,11 +58,12 @@
##
## Find a topic based on a fuzzy match
##
## @param term [String] The search term
##
- def find_topic(term)
+ def find_topic(term = nil)
+ return @topics if term.nil?
@topics.filter do |topic|
rx = term.to_rx
topic.title.downcase =~ rx
end
end
@@ -125,11 +131,12 @@
## @return [String] formatted list
##
def list_runnable
output = []
output.push(%({bg}"Runnable" Topics:{x}\n).c)
- @topics.each do |topic|
+
+ find_topic(Howzit.options[:for_topic]).each do |topic|
s_out = []
topic.tasks.each do |task|
s_out.push(task.to_list)
end
@@ -241,10 +248,15 @@
end
Process.exit 0
end
+ ##
+ ## Accessor method for note_file (path to located build note)
+ ##
+ ## @return [String] path
+ ##
def note_file
@note_file ||= find_note_file
end
private
@@ -579,11 +591,11 @@
# clear the buffer
ARGV.length.times do
ARGV.shift
end
- res = yn("No build notes file found, create one?", true)
+ res = yn("No build notes file found, create one?", false)
create_note if res
Process.exit 1
end
if Howzit.options[:title_only]
@@ -618,18 +630,18 @@
Process.exit(0)
end
topic_matches = []
if Howzit.options[:grep]
- matches = grep_topics(Howzit.options[:grep])
+ matches = grep(Howzit.options[:grep])
case Howzit.options[:multiple_matches]
when :all
- topic_matches.concat(matches.sort)
+ topic_matches.concat(matches.sort_by(&:title))
else
- topic_matches.concat(Prompt.choose(matches))
+ topic_matches.concat(Prompt.choose(matches.map(&:title), height: :max))
end
elsif Howzit.options[:choose]
- titles = Prompt.choose(list_topics)
+ titles = Prompt.choose(list_topics, height: :max)
titles.each { |title| topic_matches.push(find_topic(title)[0]) }
# If there are arguments use those to search for a matching topic
elsif !Howzit.cli_args.empty?
search = Howzit.cli_args.join(' ').strip.downcase.split(/ *, */).map(&:strip)