class Kashi::CLI
Public Class Methods
new(argv)
click to toggle source
# File lib/kashi/cli.rb, line 10 def initialize(argv) @argv = argv.dup @help = argv.empty? @filepath = 'SCfile' @options = { color: true, includes: [], excludes: [], } parser.order!(@argv) end
start(argv)
click to toggle source
# File lib/kashi/cli.rb, line 6 def self.start(argv) new(argv).run end
Public Instance Methods
run()
click to toggle source
# File lib/kashi/cli.rb, line 22 def run if @help puts parser.help elsif @apply Apply.new(@filepath, @options).run elsif @export Export.new(@filepath, @options).run end end
Private Instance Methods
parser()
click to toggle source
# File lib/kashi/cli.rb, line 34 def parser @parser ||= OptionParser.new do |opts| opts.version = VERSION opts.on('-h', '--help', 'Show help') { @help = true } opts.on('-a', '--apply', 'Apply DSL') { @apply = true } opts.on('-e', '--export', 'Export to DSL') { @export = true } opts.on('-n', '--dry-run', 'Dry run') { @options[:dry_run] = true } opts.on('', '--no-color', 'No color') { @options[:color] = false } opts.on('', '--secret-provider NAME', 'use secret value expansion') { |v| @options[:secret_provider] = v } opts.on('-s', '--split', 'Split export DLS file contact group and tests') { @options[:split] = true } opts.on('', '--split-more', 'Split export DLS file to 1 per object') { @options[:split_more] = true } opts.on('-v', '--debug', 'Show debug log') { Kashi.logger.level = Logger::DEBUG } opts.on('-i', '--include-names NAMES', 'include website_name', Array) { |v| @options[:includes] = v } opts.on('-x', '--exclude-names NAMES', 'exclude website_name by regex', Array) do |v| @options[:excludes] = v.map! do |name| name =~ /\A\/(.*)\/\z/ ? Regexp.new($1) : Regexp.new("\A#{Regexp.escape(name)}\z") end end end end