Sha256: e960c0858957f4f52e1b514647c5c67255e9613e675d64dfb14cd50c1971875f
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'optparse' require 'scaffold' # List the available templates TEMPLATES = %w[puppet module node class define function type] options = {} optparse = OptionParser.new do |opts| # Set a banner, displayed at the top # of the help screen. opts.banner = 'Usage: scaffold [options] --template="template" options ...' opts.separator '' opts.separator 'Configuration options:' options[:configdir] = nil opts.on( '-c', '--configdir=DIRECTORY', 'Specify the location of your Puppet configuration directory') do |confdir| options[:configdir] = confdir end options[:template] = nil opts.on( '--template=TEMPLATE', TEMPLATES, 'Template to create') do |template| options[:template] = template end opts.separator "" opts.separator "Common options:" opts.on_tail('-v', '--version', 'Show version') do puts Scaffold::VERSION exit end opts.on_tail('-h', '--help', 'Display this screen' ) do puts opts exit end end # Process the options and fail on invalid options or if template is not specified begin optparse.parse! mandatory = [:template] missing = mandatory.select{ |param| options[param].nil? } if not missing.empty? puts "Missing options: #{missing.join(', ')}" puts optparse exit end rescue OptionParser::InvalidArgument, OptionParser::InvalidOption, OptionParser::MissingArgument puts $!.to_s puts optparse exit end # Specify destination directory according to the template specified if options[:template] == 'puppet' if options[:configdir] dir = options[:configdir] else dir = Puppet[:confdir] end else dir = Puppet[:modulepath].split(':') end # Add generator name to ARGV ARGV.unshift(options[:template]) # Run the generator Scaffold::Generator.run_cli dir.to_s, 'scaffold', Scaffold::VERSION, ARGV
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scaffold-0.0.3 | bin/scaffold |