class Codeowners::Cli::FilesFromFZFSearch

Bring a list of suggestions using `fzf` from the current folder

Public Instance Methods

pick_suggestions() click to toggle source

Open `fzf` with {#query} to suggest a list of matching files

# File lib/codeowners/cli/suggest_file_from_pattern.rb, line 47
def pick_suggestions
  `fzf --height 50% --reverse -q #{query.inspect}`
    .lines.first&.chomp
end
query() click to toggle source

Returns shortcut of the current folders

> 'some/folder/with/file.txt' to 'some/fowi/file.txt'

# File lib/codeowners/cli/suggest_file_from_pattern.rb, line 54
def query
  dir, _, file = @pattern.gsub(/[_\-\*]+/, '').rpartition '/'
  dir.gsub(%r{/(\w{,2})[^/]+}, '\1') + # map 2 chars per folder
    file.gsub(/\.\w+/, '')             # remove extension
end