Sha256: bce0eb160502b97d5778a0a5e6547d90f9e3ca1b9c9079f607d4e096ae9ce082

Contents?: true

Size: 1.88 KB

Versions: 42

Compression:

Stored size: 1.88 KB

Contents

require 'logger'

require 'thor'

require_relative 'app'
require_relative 'metadata'


module KitchenHooks
  class Main < Thor
    desc 'version', 'Show application version'
    def version
      puts VERSION
    end


    desc 'art', 'Show application art'
    def art
      w = ART.lines.map(&:length).sort.last
      w += 1 if w % 2 != 0
      puts
      puts 'kitchen_hooks'.center(w)
      puts VERSION.center(w)
      puts
      puts SUMMARY.center(w)
      puts "\n\n\n"
      puts ART
      puts "\n\n\n"
    end


    desc 'server', 'Start application web server'
    option :port, \
      type: :numeric,
      aliases: %w[ -p ],
      desc: 'Set Sinatra port',
      default: 4567
    option :environment, \
      type: :string,
      aliases: %w[ -e ],
      desc: 'Set Sinatra environment',
      default: 'development'
    option :bind, \
      type: :string,
      aliases: %w[ -b ],
      desc: 'Set Sinatra interface',
      default: '0.0.0.0'
    option :config, \
      type: :string,
      aliases: %w[ -c ],
      desc: 'Configuration file to use',
      default: '/etc/kitchen_hooks/config.json'
    option :database, \
      type: :string,
      aliases: %w[ -d ],
      desc: 'Location of application database',
      default: '/etc/kitchen_hooks/app.db'
    option :tmpdir, \
      type: :string,
      aliases: %w[ -t ],
      desc: 'Location of temporary directory',
      default: '/tmp'
    def server
      App.config! JSON::parse(File.read(options.config))
      App.backlog!
      App.db! options.database
      App.tmp! options.tmpdir
      App.sync!
      App.set :environment, options.environment
      App.set :port, options.port
      App.set :bind, options.bind
      App.set :raise_errors, true
      App.set :dump_errors, true
      App.set :show_exceptions, true
      App.set :logging, ::Logger::DEBUG
      App.run!

      at_exit do
        App.close!
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
kitchen_hooks-2.1.1 lib/kitchen_hooks/main.rb
kitchen_hooks-2.1.0 lib/kitchen_hooks/main.rb
kitchen_hooks-2.0.2 lib/kitchen_hooks/main.rb
kitchen_hooks-2.0.1 lib/kitchen_hooks/main.rb
kitchen_hooks-2.0.0 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.11 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.10 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.9 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.8 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.7 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.6 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.5 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.4 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.1 lib/kitchen_hooks/main.rb
kitchen_hooks-1.8.0 lib/kitchen_hooks/main.rb
kitchen_hooks-1.7.26 lib/kitchen_hooks/main.rb
kitchen_hooks-1.7.25 lib/kitchen_hooks/main.rb
kitchen_hooks-1.7.24 lib/kitchen_hooks/main.rb
kitchen_hooks-1.7.23 lib/kitchen_hooks/main.rb
kitchen_hooks-1.7.22 lib/kitchen_hooks/main.rb