Sha256: 6717de0225b161d2baffd8e712862761c4155475842adfb300dfa261cce8686f
Contents?: true
Size: 1007 Bytes
Versions: 12
Compression:
Stored size: 1007 Bytes
Contents
#!/usr/bin/env ruby require 'scout' $0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands options = SOPT.setup <<EOF Print a template $ #{$0} [<options>] <template> [<VAR>=<value>]* Print a template making the substitutions that follow -h--help Print this help -s--sub* List a substitutions as a parameter instead -s--var* List a substitutions as a parameter, variable name -s--value* List a substitutions as a parameter, value EOF if options[:help] if defined? scout_usage scout_usage else puts SOPT.doc end exit 0 end template, *subs = ARGV raise MissingParameterException, :template if template.nil? txt = Scout.share.templates[template].find_with_extension('rb').read if options[:sub] subs ||= [] subs << options[:sub] end if options[:var] subs ||= [] subs << [options[:var], options[:value]] * "=" end subs.each do |sub| key, value = sub.split("=") txt.gsub!(key, value) end puts txt
Version data entries
12 entries across 12 versions & 1 rubygems