Sha256: 32eca20bcf17eb51cfae364e0c0f412df208ebfd4fbc04bde2576daa5bdc7543

Contents?: true

Size: 845 Bytes

Versions: 5

Compression:

Stored size: 845 Bytes

Contents

module Oxidized
  class CLI
    require 'oxidized'
    require 'slop'

    def run
      Process.daemon if @opts[:daemonize]
      begin
        Oxidized.new
      rescue => error
        crash error
        raise
      end
    end

    private

    def initialize
      _args, @opts = parse_opts
      CFG.debug = true if @opts[:debug]
    end

    def crash error
      open Config::Crash, 'w' do |file|
        file.puts '-' * 50
        file.puts Time.now.utc
        file.puts error.message + ' [' + error.class.to_s + ']'
        file.puts '-' * 50
        file.puts error.backtrace
        file.puts '-' * 50
      end
    end

    def parse_opts
      opts = Slop.new(:help=>true) do
        on 'd', 'debug', 'turn on debugging'
        on 'daemonize',  'Daemonize/fork the process'
      end
      [opts.parse!, opts]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oxidized-0.2.3 lib/oxidized/cli.rb
oxidized-0.2.2 lib/oxidized/cli.rb
oxidized-0.2.1 lib/oxidized/cli.rb
oxidized-0.2.0 lib/oxidized/cli.rb
oxidized-0.1.1 lib/oxidized/cli.rb