Module: SnippetCli::EspansoConfig

Defined in:
lib/snippet_cli/espanso_config.rb

Overview

Discovers Espanso config paths by shelling out to ‘espanso path`.

Class Method Summary collapse

Class Method Details

.match_dirObject

Returns the match directory path (e.g. ~/.config/espanso/match).

Raises:



11
12
13
14
15
16
17
18
19
# File 'lib/snippet_cli/espanso_config.rb', line 11

def self.match_dir
  output, status = Open3.capture2('espanso', 'path')
  raise EspansoConfigError, 'Could not determine Espanso config path. Is espanso installed?' unless status.success?

  config_line = output.lines.find { |l| l.start_with?('Config:') }
  raise EspansoConfigError, 'Could not determine Espanso config path from `espanso path` output.' unless config_line

  File.join(config_line.split(':', 2).last.strip, 'match')
end

.match_filesObject

Returns sorted list of .yml files in the match directory.



22
23
24
# File 'lib/snippet_cli/espanso_config.rb', line 22

def self.match_files
  Dir.glob(File.join(match_dir, '**', '*.yml'), sort: true)
end