2015-03-05 00:10:08 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require "json"
|
|
|
|
|
|
|
|
commands = {}
|
|
|
|
|
|
|
|
Dir["#{ENV["TLDRHOME"]}/pages/**/*.md"].each do |file|
|
|
|
|
# "./pages/osx/xsltproc.md",
|
|
|
|
file = file.split("/")
|
|
|
|
name = file.pop().gsub(".md","")
|
|
|
|
platform = file.pop()
|
|
|
|
|
|
|
|
unless commands.key?(name)
|
|
|
|
commands[name] = {
|
|
|
|
name: name,
|
|
|
|
platform: [platform]
|
2015-09-22 10:08:04 +01:00
|
|
|
}
|
2015-03-05 00:10:08 +00:00
|
|
|
else
|
|
|
|
commands[name][:platform] << platform
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-22 10:08:04 +01:00
|
|
|
commands = commands.sort.map do |k,v| v end
|
2015-03-05 00:10:08 +00:00
|
|
|
|
|
|
|
File.write("#{ENV["TLDRHOME"]}/pages/index.json", {commands: commands}.to_json)
|