Module: SnippetCli::MatchFileWriter
- Defined in:
- lib/snippet_cli/match_file_writer.rb
Overview
Appends a generated snippet YAML string to an Espanso match file. Uses string-level append (not YAML round-trip) to preserve formatting.
Class Method Summary collapse
-
.append(file_path, snippet_yaml) ⇒ Object
Appends the snippet to the given file, indenting it by 2 spaces to sit under the top-level ‘matches:` key.
Class Method Details
.append(file_path, snippet_yaml) ⇒ Object
Appends the snippet to the given file, indenting it by 2 spaces to sit under the top-level ‘matches:` key.
13 14 15 16 17 18 |
# File 'lib/snippet_cli/match_file_writer.rb', line 13 def self.append(file_path, snippet_yaml) existing = FileHelper.read_or_empty(file_path) indented = snippet_yaml.lines.map { |line| " #{line}" }.join content = build_content(existing, indented) FileWriter.write(file_path, content) end |