/usr/bin/mustache is in ruby-mustache 1.0.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #!/usr/bin/ruby
require 'yaml'
require 'optparse'
require 'mustache'
require 'mustache/version'
class Mustache
class CLI
# Return a structure describing the options.
def self.parse_options(args)
opts = OptionParser.new do |opts|
opts.banner = "Usage: mustache [-c] [-t] [-r library] FILE ..."
opts.separator " "
opts.separator "Examples:"
opts.separator " $ mustache data.yml template.mustache"
opts.separator " $ cat data.yml | mustache - template.mustache"
opts.separator " $ mustache -c template.mustache"
opts.separator " "
opts.separator " See mustache(1) or " +
"http://mustache.github.com/mustache.1.html"
opts.separator " for more details."
opts.separator " "
opts.separator "Options:"
opts.on("-c", "--compile FILE",
"Print the compiled Ruby for a given template.") do |file|
puts Mustache::Template.new(File.read(file)).compile
exit
end
opts.on("-t", "--tokens FILE",
"Print the tokenized form of a given template.") do |file|
require 'pp'
pp Mustache::Template.new(File.read(file)).tokens
exit
end
opts.on('-r', '--require LIB', 'Require a Ruby library before running.') do |lib|
require lib
end
opts.separator "Common Options:"
opts.on("-v", "--version", "Print the version") do |v|
puts "Mustache v#{Mustache::VERSION}"
exit
end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end
opts.separator ""
opts.parse!(args)
end
# Does the dirty work of reading files from the command line then
# processing them. The meat of this script, if you will.
def self.process_files(input_files)
doc = input_files.file.read
yaml = nil
begin
yaml = YAML.load_stream(doc)
rescue
abort "Unable to parse yaml!"
end
if yaml.nil?
puts Mustache.render(doc)
else
template = input_files.skip.file.read
puts Mustache.render template, yaml.compact.reduce(&:merge)
end
end
end
end
# Help is the default.
ARGV << '-h' if ARGV.empty? && $stdin.tty?
# Process options
Mustache::CLI.parse_options(ARGV) if $stdin.tty?
# Still here - process rest of ARGF
Mustache::CLI.process_files(ARGF)
|