7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/tty/files.rb', line 7
def select_element_from_file_system(text: "", pattern: "*", path: ".", multi_select: false, **options)
pathnames = get_pathnames_from_path(pattern, path)
file_names = pathnames.map do |pathname|
pathname.basename.to_s
end
unless multi_select
selected_element = self.select(text, file_names, **options)
return get_selected_element_full_path(pathnames, selected_element)
end
selected_elements = self.multi_select(text, file_names, **options)
selected_elements.map do |selected_element|
get_selected_element_full_path(pathnames, selected_element)
end
end
|