#!/usr/bin/env ruby require 'optparse' require 'minke' ASCII_ART = < './config.yml' } subtext = < OptionParser.new do |opts| # ... end, 'build' => OptionParser.new do |opts| # ... end, 'test' => OptionParser.new do |opts| opts.banner = "Usage: minke test [options]" opts.on("-c", "--config", "Load config file at given path") { |c| options[:config] = c } end } global.order! command = ARGV.shift subcommands[command].order! def load_config options reader = Minke::Config::Reader.new Minke::Logging.create_logger(options[:verbose]) config = reader.read options[:config] variables = Minke::Generators::ConfigVariables.new.tap do |v| v.application_name = config.application_name v.namespace = config.namespace v.src_root = File.expand_path('../') end processor = Minke::Generators::Processor.new variables, nil, Minke::Logging.create_logger(options[:verbose]) generator_config = processor.get_generator config.generator_name return config, generator_config end config, generator_config = load_config options case command when "test" Minke::Command.new( config, generator_config, options[:verbose] ).test when "build" Minke::Command.new( config, generator_config, options[:verbose] ).build when "fetch" Minke::Command.new( config, generator_config, options[:verbose] ).fetch when "cucumber" Minke::Command.new( config, generator_config, options[:verbose] ).cucumber when "build_image" Minke::Command.new( config, generator_config, options[:verbose] ).build_image when "run" Minke::Command.new( config, generator_config, options[:verbose] ).run when "push" Minke::Command.new( config, generator_config, options[:verbose] ).run end exit 0 OptionParser.new do |opts| opts.banner = "Usage: minke [options]" opts.on('-e', '--encrypt STRING', 'Encrypt a string') { |v| options[:encrypt] = v } opts.on('-k', '--key STRING', 'Private key to use for encryption') { |v| options[:key] = v } opts.on('-g', '--generator GENERATOR', 'Generator plugin to use') { |v| options[:generator] = v } opts.on('-o', '--output OUTPUT', 'Output folder') { |v| options[:output] = v } opts.on('-a', '--application_name NAME', 'Application name') { |v| options[:name] = v } opts.on('-n', '--namespace NAMESPACE', 'Application namespace') { |v| options[:namespace] = v } end.parse! # load the installed generators variables = Minke::Generators::ConfigVariables.new.tap do |v| v.application_name = options[:name] v.namespace = options[:namespace] v.src_root = File.expand_path(options[:output]) unless options[:output] == nil end processor = Minke::Generators::Processor.new variables, Minke::Docker::DockerRunner.new if options[:encrypt] != nil puts "Please specify a key to use for encryption using -k [path to file]" if options[:key] == nil encrypt = Minke::Encryption::Encryption.new options[:key] puts 'Copy the below to your minke config file:' puts '' puts 'secure:' puts " fingerprint: #{encrypt.fingerprint}" puts ' value: >' encrypt.encrypt_string(options[:encrypt]).split("\n").each { |l| puts " #{l}"} exit 0 end if options[:generator] == nil || options[:output] == nil || options[:name] == nil || options[:namespace] == nil puts "Please specify options use: minke --help for help on command line options" exit 0 end processor.process options[:generator], options[:output]