Sha256: 0f12a9b30ce9b51d0df59ee540897dcc47ba7c2c6a903dc7db0329a4d3765dd8

Contents?: true

Size: 807 Bytes

Versions: 5

Compression:

Stored size: 807 Bytes

Contents

require 'highline/import'
require 'rcoli/utils'
require 'rcoli/extensions'
require 'rcoli/help'
require 'rcoli/model'


@program = RCoLi::Program.new

def application(id, &block)
  @program.name id
  
  @program.switch long: 'debug' do |s|
    s.description "Turn on debugging"
  end
  
  @program.command(:help) do |c|
    c.description "Display help documentation"
    c.skip_pre true
    c.skip_post true
    c.force true
    c.action do |global_opts, opts, args|
      @program.help args
    end
  end
  
  @program.instance_eval &block
  
end

at_exit {
  begin
    @program.execute(ARGV, self)
  rescue InvalidCommand => e
    say "#{@program.value_of_name}: #{e.message}. See '#{@program.value_of_name} help'"
  rescue ApplicationError => e
    say($terminal.color "#{e.message}", :red)
  end
    
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rcoli-0.5.12 lib/rcoli.rb
rcoli-0.5.11 lib/rcoli.rb
rcoli-0.5.10 lib/rcoli.rb
rcoli-0.5.9 lib/rcoli.rb
rcoli-0.5.8 lib/rcoli.rb