<commit_before>require 'thor'

require 'fireap/config'
require 'fireap/context'
require 'fireap/deployer'
require 'fireap/watcher'

module Fireap
  class CLI < Thor
    @ctx
    package_name "Fireap::CLI"
    class_option 'config',  :aliases => 'c'
    class_option 'debug',   :aliases => 'd'

    desc 'deploy', 'Deploy target app'
    option 'app', :required => true, :aliases => 'a'
    option 'version', :aliases => 'v'
    def deploy
      load_context(options)
      Fireap::Deployer.new(options, ctx: @ctx).start(options)
    end

    desc 'watch', 'Watch Deploy Event'
    option 'dry-run', :aliases => 'n'
    def watch
      load_context(options)
      Fireap::Watcher.new(options, ctx: @ctx).wait_and_handle
    end

    desc 'clear', 'Clear deploy lock of target app'
    option 'app', :required => true, :aliases => 'a'
    def clear
      load_context(options)
      Fireap::Deployer.new(options, ctx: @ctx).release_lock
      puts "Successfully cleared lock for app=#{options['app']}."
    end

    private

    def load_context(options)
      @ctx ||= proc {
        opt = {
          config_path:  options['config'],
          dry_run:      options['dry-run'],
          develop_mode: options['debug'],
        }
        Fireap::Context.new(opt)
      }.call
      if ! @ctx.develop_mode? and options['debug']
        @ctx.log.warn %q[You specified DEBUG option. But DEBUG mode is disabled by configuration. Please set `enable_debugging = "ON"` in your config file.]
      end
    end
  end
end<commit_msg>Rename subcommands. deploy => 'fire', watch => 'reap'<commit_after>require 'thor'

require 'fireap/config'
require 'fireap/context'
require 'fireap/deployer'
require 'fireap/watcher'

module Fireap
  class CLI < Thor
    @ctx
    package_name "Fireap::CLI"
    class_option 'config',  :aliases => 'c'
    class_option 'debug',   :aliases => 'd'

    desc 'fire', 'Fire deploy event for target Application'
    option 'app', :required => true, :aliases => 'a'
    option 'version', :aliases => 'v'
    def fire
      load_context(options)
      Fireap::Deployer.new(options, ctx: @ctx).start(options)
    end

    desc 'reap', 'Watch and Reap a deploy event'
    option 'dry-run', :aliases => 'n'
    def reap
      load_context(options)
      Fireap::Watcher.new(options, ctx: @ctx).wait_and_handle
    end

    desc 'clear', 'Clear deploy lock of target app'
    option 'app', :required => true, :aliases => 'a'
    def clear
      load_context(options)
      Fireap::Deployer.new(options, ctx: @ctx).release_lock
      puts "Successfully cleared lock for app=#{options['app']}."
    end

    private

    def load_context(options)
      @ctx ||= proc {
        opt = {
          config_path:  options['config'],
          dry_run:      options['dry-run'],
          develop_mode: options['debug'],
        }
        Fireap::Context.new(opt)
      }.call
      if ! @ctx.develop_mode? and options['debug']
        @ctx.log.warn %q[You specified DEBUG option. But DEBUG mode is disabled by configuration. Please set `enable_debugging = "ON"` in your config file.]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13102119460500963, 'fraction_numerical': 0.0, 'mean_word_length': 2.850432632880099, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6371196', 'n_tokens_mistral': 1006, 'n_tokens_neox': 984, 'n_words': 276}