Sha256: 9036ba579b9a430242943ffc7da01eb81768be629315fa36856719de3d2bc436

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

#!/usr/bin/env ruby

# These would not be in a real GLI app; we do this so we can easily run this on the command line
$: << File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','lib'))
$: << File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))

require 'gli'
require 'todo/version'


include GLI::App

program_desc 'Manages tasks'

config_file "gli_test_todo.rc"

flag :flag
switch :switch
switch :otherswitch, :negatable => true

version Todo::VERSION

commands_from 'todo/commands'

command :first  do |c| c.action { |g,o,a| puts "first: #{a.join(',')}" } end
command :second do |c| c.action { |g,o,a| puts "second: #{a.join(',')}" } end

command :chained         => [ :first, :second ]
command [:chained2,:ch2] => [ :second, :first ]

pre do |global,command,options,args|
  # Pre logic here
  # Return true to proceed; false to abourt and not call the
  # chosen command
  # Use skips_pre before a command to skip this block
  # on that command only
  true
end

post do |global,command,options,args|
  # Post logic here
  # Use skips_post before a command to skip this
  # block on that command only
end

on_error do |exception|
  # Error logic here
  # return false to skip default error handling
  true
end

exit run(ARGV)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gli-2.0.0.rc6 test/apps/todo/bin/todo
gli-2.0.0.rc5 test/apps/todo/bin/todo
gli-2.0.0.rc4 test/apps/todo/bin/todo
gli-2.0.0.rc3 test/apps/todo/bin/todo