145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/na/next_action.rb', line 145
def find_actions(target, search, tagged = nil, all: false, done: false)
_, actions, projects = parse_actions(search: search, require_na: false, file_path: target, tag: tagged, done: done)
unless actions.count.positive?
NA.notify("{r}No matching actions found in {bw}#{File.basename(target, ".#{NA.extension}")}")
return
end
return [projects, actions] if actions.count == 1 || all
options = actions.map { |action| "#{action.line} % #{action.parent.join('/')} : #{action.action}" }
res = choose_from(options, prompt: 'Make a selection: ', multiple: true, sorted: true)
NA.notify('{r}Cancelled', exit_code: 1) unless res && res.length.positive?
selected = []
res.each do |result|
idx = result.match(/^(\d+)(?= % )/)[1]
action = actions.select { |a| a.line == idx.to_i }.first
selected.push(action)
end
[projects, selected]
end
|