mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
38 lines
846 B
Ruby
Executable file
38 lines
846 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
require_relative '../lib/utils/frontmatter_converter'
|
|
|
|
if ARGV.empty?
|
|
puts "Usage: convert-frontmatter FILE [FILE...]"
|
|
puts ""
|
|
puts "Converts front-matter from custom format to YAML in-place."
|
|
puts ""
|
|
puts "Examples:"
|
|
puts " convert-frontmatter posts/2025/11/*.md"
|
|
puts " convert-frontmatter posts/**/*.md"
|
|
exit 1
|
|
end
|
|
|
|
converted_count = 0
|
|
error_count = 0
|
|
|
|
ARGV.each do |file_path|
|
|
unless File.exist?(file_path)
|
|
puts "ERROR: File not found: #{file_path}"
|
|
error_count += 1
|
|
next
|
|
end
|
|
|
|
begin
|
|
Pressa::Utils::FrontmatterConverter.convert_file(file_path)
|
|
puts "✓ #{file_path}"
|
|
converted_count += 1
|
|
rescue => e
|
|
puts "ERROR: #{file_path}: #{e.message}"
|
|
error_count += 1
|
|
end
|
|
end
|
|
|
|
puts ""
|
|
puts "Converted: #{converted_count}"
|
|
puts "Errors: #{error_count}" if error_count > 0
|
|
|