gli 1.6.0 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.gitignore +11 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +10 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE.txt +201 -0
  6. data/ObjectModel.graffle +1191 -0
  7. data/README.rdoc +60 -10
  8. data/Rakefile +145 -0
  9. data/bin/gli +12 -30
  10. data/bin/report_on_rake_results +10 -0
  11. data/bin/test_all_rubies.sh +6 -0
  12. data/features/gli_executable.feature +84 -0
  13. data/features/gli_init.feature +219 -0
  14. data/features/step_definitions/gli_executable_steps.rb +12 -0
  15. data/features/step_definitions/gli_init_steps.rb +11 -0
  16. data/features/step_definitions/todo_steps.rb +69 -0
  17. data/features/support/env.rb +49 -0
  18. data/features/todo.feature +182 -0
  19. data/gli.cheat +95 -0
  20. data/gli.gemspec +34 -0
  21. data/lib/gli.rb +11 -571
  22. data/lib/gli/app.rb +184 -0
  23. data/lib/gli/app_support.rb +226 -0
  24. data/lib/gli/command.rb +107 -95
  25. data/lib/gli/command_line_option.rb +34 -0
  26. data/lib/gli/command_line_token.rb +13 -9
  27. data/lib/gli/command_support.rb +200 -0
  28. data/lib/gli/commands/compound_command.rb +42 -0
  29. data/lib/gli/commands/help.rb +63 -0
  30. data/lib/gli/commands/help_modules/command_help_format.rb +134 -0
  31. data/lib/gli/commands/help_modules/global_help_format.rb +61 -0
  32. data/lib/gli/commands/help_modules/list_formatter.rb +22 -0
  33. data/lib/gli/commands/help_modules/options_formatter.rb +50 -0
  34. data/lib/gli/commands/help_modules/text_wrapper.rb +53 -0
  35. data/lib/gli/commands/initconfig.rb +67 -0
  36. data/lib/{support → gli/commands}/scaffold.rb +150 -34
  37. data/lib/gli/dsl.rb +194 -0
  38. data/lib/gli/exceptions.rb +13 -4
  39. data/lib/gli/flag.rb +30 -41
  40. data/lib/gli/gli_option_parser.rb +98 -0
  41. data/lib/gli/option_parser_factory.rb +44 -0
  42. data/lib/gli/options.rb +2 -1
  43. data/lib/gli/switch.rb +19 -51
  44. data/lib/gli/terminal.rb +30 -20
  45. data/lib/gli/version.rb +5 -0
  46. data/test/apps/README.md +2 -0
  47. data/test/apps/todo/Gemfile +2 -0
  48. data/test/apps/todo/README.rdoc +6 -0
  49. data/test/apps/todo/Rakefile +23 -0
  50. data/test/apps/todo/bin/todo +52 -0
  51. data/test/apps/todo/lib/todo/commands/create.rb +22 -0
  52. data/test/apps/todo/lib/todo/commands/list.rb +53 -0
  53. data/test/apps/todo/lib/todo/commands/ls.rb +47 -0
  54. data/test/apps/todo/lib/todo/version.rb +3 -0
  55. data/test/apps/todo/test/tc_nothing.rb +14 -0
  56. data/test/apps/todo/todo.gemspec +23 -0
  57. data/test/apps/todo/todo.rdoc +5 -0
  58. data/test/config.yaml +10 -0
  59. data/test/fake_std_out.rb +30 -0
  60. data/test/gli.reek +122 -0
  61. data/test/init_simplecov.rb +8 -0
  62. data/test/option_test_helper.rb +13 -0
  63. data/test/roodi.yaml +18 -0
  64. data/test/tc_command.rb +260 -0
  65. data/test/tc_compount_command.rb +22 -0
  66. data/test/tc_flag.rb +56 -0
  67. data/test/tc_gli.rb +611 -0
  68. data/test/tc_help.rb +223 -0
  69. data/test/tc_options.rb +31 -0
  70. data/test/tc_subcommands.rb +162 -0
  71. data/test/tc_switch.rb +57 -0
  72. data/test/tc_terminal.rb +97 -0
  73. data/test/test_helper.rb +13 -0
  74. metadata +318 -49
  75. data/lib/gli_version.rb +0 -3
  76. data/lib/support/help.rb +0 -179
  77. data/lib/support/initconfig.rb +0 -34
  78. data/lib/support/rdoc.rb +0 -119
@@ -0,0 +1,61 @@
1
+ require 'erb'
2
+
3
+ module GLI
4
+ module Commands
5
+ module HelpModules
6
+ class GlobalHelpFormat
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ def format
12
+ program_desc = @app.program_desc
13
+
14
+ command_formatter = ListFormatter.new(@app.commands.values.sort.reject(&:nodoc).map { |command|
15
+ [[command.name,Array(command.aliases)].flatten.join(', '),command.description]
16
+ })
17
+ stringio = StringIO.new
18
+ command_formatter.output(stringio)
19
+ commands = stringio.string
20
+
21
+ global_option_descriptions = OptionsFormatter.new(global_flags_and_switches).format
22
+
23
+ GLOBAL_HELP.result(binding)
24
+ end
25
+
26
+ private
27
+
28
+ GLOBAL_HELP = ERB.new(%q(NAME
29
+ <%= File.basename($0) %> - <%= program_desc %>
30
+
31
+ SYNOPSIS
32
+ <%= usage_string %>
33
+
34
+ <% unless @app.version_string.nil? %>
35
+ VERSION
36
+ <%= @app.version_string %>
37
+
38
+ <% end %>
39
+ <% unless global_flags_and_switches.empty? %>
40
+ GLOBAL OPTIONS
41
+ <%= global_option_descriptions %>
42
+
43
+ <% end %>
44
+ COMMANDS
45
+ <%= commands %>),nil,'<>')
46
+
47
+ def global_flags_and_switches
48
+ @app.flags.merge(@app.switches)
49
+ end
50
+
51
+ def usage_string
52
+ "#{File.basename($0)} ".tap do |string|
53
+ string << "[global options] " unless global_flags_and_switches.empty?
54
+ string << "command "
55
+ string << "[command options] [arguments...]"
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,22 @@
1
+ module GLI
2
+ module Commands
3
+ module HelpModules
4
+ # Given a list of two-element lists, formats on the terminal
5
+ class ListFormatter
6
+ def initialize(list)
7
+ @list = list
8
+ end
9
+
10
+ # Output the list to the output_device
11
+ def output(output_device)
12
+ return if @list.empty?
13
+ max_width = @list.map { |_| _[0].length }.max
14
+ wrapper = TextWrapper.new(Terminal.instance.size[0],4 + max_width + 3)
15
+ @list.each do |(name,description)|
16
+ output_device.printf(" %-#{max_width}s - %s\n",name,wrapper.wrap(String(description).strip))
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,50 @@
1
+ module GLI
2
+ module Commands
3
+ module HelpModules
4
+ class OptionsFormatter
5
+ def initialize(flags_and_switches)
6
+ @flags_and_switches = flags_and_switches
7
+ end
8
+
9
+ def format
10
+ list_formatter = ListFormatter.new(@flags_and_switches.values.sort { |a,b|
11
+ a.name.to_s <=> b.name.to_s
12
+ }.map { |option|
13
+ if option.respond_to? :argument_name
14
+ [option_names_for_help_string(option,option.argument_name),description_with_default(option)]
15
+ else
16
+ [option_names_for_help_string(option),description_with_default(option)]
17
+ end
18
+ })
19
+ stringio = StringIO.new
20
+ list_formatter.output(stringio)
21
+ stringio.string
22
+ end
23
+
24
+ private
25
+
26
+ def description_with_default(option)
27
+ if option.kind_of? Flag
28
+ String(option.description) + " (default: #{option.default_value || 'none'})"
29
+ else
30
+ String(option.description)
31
+ end
32
+ end
33
+
34
+ def option_names_for_help_string(option,arg_name=nil)
35
+ names = [option.name,Array(option.aliases)].flatten
36
+ names = names.map { |name| CommandLineOption.name_as_string(name,option.kind_of?(Switch) ? option.negatable? : false) }
37
+ if arg_name.nil?
38
+ names.join(', ')
39
+ else
40
+ if names[-1] =~ /^--/
41
+ names.join(', ') + "=#{arg_name}"
42
+ else
43
+ names.join(', ') + " #{arg_name}"
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,53 @@
1
+ module GLI
2
+ module Commands
3
+ module HelpModules
4
+ # Handles wrapping text
5
+ class TextWrapper
6
+ # Create a text_wrapper wrapping at the given width,
7
+ # and indent.
8
+ def initialize(width,indent)
9
+ @width = width
10
+ @indent = indent
11
+ end
12
+
13
+ # Return a wrapped version of text, assuming that the first line has already been
14
+ # indented by @indent characters. Resulting text does NOT have a newline in it.
15
+ def wrap(text)
16
+ return text if text.nil?
17
+ wrapped_text = ''
18
+ current_graf = ''
19
+
20
+ paragraphs = text.split(/\n\n+/)
21
+ paragraphs.each do |graf|
22
+ current_line = ''
23
+ current_line_length = @indent
24
+
25
+ words = graf.split(/\s+/)
26
+ current_line = words.shift || ''
27
+ current_line_length += current_line.length
28
+
29
+ words.each do |word|
30
+ if current_line_length + word.length + 1 > @width
31
+ current_graf << current_line << "\n"
32
+ current_line = ''
33
+ current_line << ' ' * @indent << word
34
+ current_line_length = @indent + word.length
35
+ else
36
+ if current_line == ''
37
+ current_line << word
38
+ else
39
+ current_line << ' ' << word
40
+ end
41
+ current_line_length += (word.length + 1)
42
+ end
43
+ end
44
+ current_graf << current_line
45
+ wrapped_text << current_graf << "\n\n" << ' ' * @indent
46
+ current_graf = ''
47
+ end
48
+ wrapped_text.gsub(/[\n\s]*\Z/,'')
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,67 @@
1
+ require 'gli'
2
+ require 'gli/command'
3
+ require 'yaml'
4
+
5
+ module GLI
6
+ # Command that initializes the configuration file for apps that use it.
7
+ class InitConfig < Command # :nodoc:
8
+ COMMANDS_KEY = 'commands'
9
+
10
+ def initialize(config_file_name,commands,flags,switches)
11
+ @filename = config_file_name
12
+ super(:names => :initconfig,
13
+ :description => "Initialize the config file using current global options",
14
+ :long_desc => 'Initializes a configuration file where you can set default options for command line flags, both globally and on a per-command basis. These defaults override the built-in defaults and allow you to omit commonly-used command line flags when invoking this program')
15
+
16
+ self.desc 'force overwrite of existing config file'
17
+ self.switch :force
18
+
19
+ @commands = commands
20
+ @flags = flags
21
+ @switches = switches
22
+ end
23
+
24
+ def execute(global_options,options,arguments)
25
+ if options[:force] || !File.exist?(@filename)
26
+ create_config(global_options,options,arguments)
27
+ else
28
+ raise "Not overwriting existing config file #{@filename}, use --force to override"
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def create_config(global_options,options,arguments)
35
+ config = Hash[global_options.map { |option_name,option_value|
36
+ if option_value.kind_of?(String) && option_value.respond_to?(:force_encoding)
37
+ [option_name,option_value.force_encoding("utf-8")]
38
+ else
39
+ [option_name,option_value]
40
+ end
41
+ }]
42
+ config[COMMANDS_KEY] = {}
43
+ @commands.each do |name,command|
44
+ if (command != self) && (name != :rdoc) && (name != :help)
45
+ if command != self
46
+ config[COMMANDS_KEY][name.to_sym] = config_for_command(@commands,name.to_sym)
47
+ end
48
+ end
49
+ end
50
+ File.open(@filename,'w', 0600) do |file|
51
+ YAML.dump(config,file)
52
+ end
53
+ end
54
+
55
+ def config_for_command(commands,command_name)
56
+ {}.tap do |hash|
57
+ subcommands = commands[command_name].commands
58
+ subcommands.each do |name,subcommand|
59
+ next unless name.kind_of? Symbol
60
+ hash[COMMANDS_KEY] ||= {}
61
+ puts "#{command_name}:#{name}"
62
+ hash[COMMANDS_KEY][name.to_sym] = config_for_command(subcommands,name)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -2,9 +2,17 @@ require 'gli'
2
2
  require 'fileutils'
3
3
 
4
4
  module GLI
5
+ module Commands
5
6
  class Scaffold #:nodoc:
6
7
 
7
- def self.create_scaffold(root_dir,create_test_dir,create_ext_dir,project_name,commands,force=false,dry_run=false)
8
+ def self.create_scaffold(root_dir,
9
+ create_test_dir,
10
+ create_ext_dir,
11
+ project_name,
12
+ commands,
13
+ force=false,
14
+ dry_run=false,
15
+ create_rvmrc=false)
8
16
  dirs = [File.join(root_dir,project_name,'lib')]
9
17
  dirs << File.join(root_dir,project_name,'bin')
10
18
  dirs << File.join(root_dir,project_name,'test') if create_test_dir
@@ -15,7 +23,14 @@ module GLI
15
23
  mk_readme(root_dir,dry_run,project_name)
16
24
  mk_gemspec(root_dir,dry_run,project_name)
17
25
  mk_rakefile(root_dir,dry_run,project_name,create_test_dir)
18
- mk_version(root_dir,dry_run,project_name)
26
+ mk_lib_files(root_dir,dry_run,project_name)
27
+ if create_rvmrc
28
+ rvmrc = File.join(root_dir,project_name,".rvmrc")
29
+ File.open(rvmrc,'w') do |file|
30
+ file.puts "rvm use #{ENV['rvm_ruby_string']}@#{project_name} --create"
31
+ end
32
+ puts "Created #{rvmrc}"
33
+ end
19
34
  end
20
35
  end
21
36
 
@@ -39,7 +54,7 @@ module GLI
39
54
  File.open("#{root_dir}/#{project_name}/#{project_name}.gemspec",'w') do |file|
40
55
  file.puts <<EOS
41
56
  # Ensure we require the local version and not one we might have installed already
42
- require File.join([File.dirname(__FILE__),'lib','#{project_name}_version.rb'])
57
+ require File.join([File.dirname(__FILE__),'lib','#{project_name}','version.rb'])
43
58
  spec = Gem::Specification.new do |s|
44
59
  s.name = '#{project_name}'
45
60
  s.version = #{project_name_as_module_name(project_name)}::VERSION
@@ -51,7 +66,8 @@ spec = Gem::Specification.new do |s|
51
66
  # Add your other files here if you make them
52
67
  s.files = %w(
53
68
  bin/#{project_name}
54
- lib/#{project_name}_version.rb
69
+ lib/#{project_name}/version.rb
70
+ lib/#{project_name}.rb
55
71
  )
56
72
  s.require_paths << 'lib'
57
73
  s.has_rdoc = true
@@ -61,7 +77,8 @@ lib/#{project_name}_version.rb
61
77
  s.executables << '#{project_name}'
62
78
  s.add_development_dependency('rake')
63
79
  s.add_development_dependency('rdoc')
64
- s.add_runtime_dependency('gli')
80
+ s.add_development_dependency('aruba')
81
+ s.add_runtime_dependency('gli','#{GLI::VERSION}')
65
82
  end
66
83
  EOS
67
84
  end
@@ -72,16 +89,26 @@ EOS
72
89
  project_name.split(/_/).map { |part| part[0..0].upcase + part[1..-1] }.join('')
73
90
  end
74
91
 
75
- def self.mk_version(root_dir,dry_run,project_name)
92
+ def self.mk_lib_files(root_dir,dry_run,project_name)
76
93
  return if dry_run
77
- File.open("#{root_dir}/#{project_name}/lib/#{project_name}_version.rb",'w') do |file|
94
+ FileUtils.mkdir("#{root_dir}/#{project_name}/lib/#{project_name}")
95
+ File.open("#{root_dir}/#{project_name}/lib/#{project_name}/version.rb",'w') do |file|
78
96
  file.puts <<EOS
79
97
  module #{project_name_as_module_name(project_name)}
80
98
  VERSION = '0.0.1'
81
99
  end
82
100
  EOS
83
101
  end
84
- puts "Created #{root_dir}/#{project_name}/lib/#{project_name}_version.rb"
102
+ puts "Created #{root_dir}/#{project_name}/lib/#{project_name}/version.rb"
103
+ File.open("#{root_dir}/#{project_name}/lib/#{project_name}.rb",'w') do |file|
104
+ file.puts <<EOS
105
+ require '#{project_name}/version.rb'
106
+
107
+ # Add requires for other files you add to your project here, so
108
+ # you just need to require this one file in your bin file
109
+ EOS
110
+ end
111
+ puts "Created #{root_dir}/#{project_name}/lib/#{project_name}.rb"
85
112
  end
86
113
  def self.mk_rakefile(root_dir,dry_run,project_name,create_test_dir)
87
114
  return if dry_run
@@ -91,7 +118,14 @@ require 'rake/clean'
91
118
  require 'rubygems'
92
119
  require 'rubygems/package_task'
93
120
  require 'rdoc/task'
94
-
121
+ EOS
122
+ if create_test_dir
123
+ file.puts <<EOS
124
+ require 'cucumber'
125
+ require 'cucumber/rake/task'
126
+ EOS
127
+ end
128
+ file.puts <<EOS
95
129
  Rake::RDocTask.new do |rd|
96
130
  rd.main = "README.rdoc"
97
131
  rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
@@ -102,23 +136,47 @@ spec = eval(File.read('#{project_name}.gemspec'))
102
136
 
103
137
  Gem::PackageTask.new(spec) do |pkg|
104
138
  end
139
+ EOS
140
+ if create_test_dir
141
+ file.puts <<EOS
142
+ CUKE_RESULTS = 'results.html'
143
+ CLEAN << CUKE_RESULTS
144
+ desc 'Run features'
145
+ Cucumber::Rake::Task.new(:features) do |t|
146
+ opts = "features --format html -o \#{CUKE_RESULTS} --format progress -x"
147
+ opts += " --tags \#{ENV['TAGS']}" if ENV['TAGS']
148
+ t.cucumber_opts = opts
149
+ t.fork = false
150
+ end
105
151
 
152
+ desc 'Run features tagged as work-in-progress (@wip)'
153
+ Cucumber::Rake::Task.new('features:wip') do |t|
154
+ tag_opts = ' --tags ~@pending'
155
+ tag_opts = ' --tags @wip'
156
+ t.cucumber_opts = "features --format html -o \#{CUKE_RESULTS} --format pretty -x -s\#{tag_opts}"
157
+ t.fork = false
158
+ end
159
+
160
+ task :cucumber => :features
161
+ task 'cucumber:wip' => 'features:wip'
162
+ task :wip => 'features:wip'
106
163
  EOS
164
+ end
107
165
  if create_test_dir
108
166
  file.puts <<EOS
109
167
  require 'rake/testtask'
110
168
  Rake::TestTask.new do |t|
111
169
  t.libs << "test"
112
- t.test_files = FileList['test/tc_*.rb']
170
+ t.test_files = FileList['test/*_test.rb']
113
171
  end
114
172
 
115
- task :default => :test
173
+ task :default => [:test,:features]
116
174
  EOS
117
- File.open("#{root_dir}/#{project_name}/test/tc_nothing.rb",'w') do |test_file|
175
+ File.open("#{root_dir}/#{project_name}/test/default_test.rb",'w') do |test_file|
118
176
  test_file.puts <<EOS
119
- require 'test/unit'
177
+ require 'test_helper'
120
178
 
121
- class TC_testNothing < Test::Unit::TestCase
179
+ class DefaultTest < Test::Unit::TestCase
122
180
 
123
181
  def setup
124
182
  end
@@ -132,7 +190,21 @@ class TC_testNothing < Test::Unit::TestCase
132
190
  end
133
191
  EOS
134
192
  end
135
- puts "Created #{root_dir}/#{project_name}/test/tc_nothing.rb"
193
+ puts "Created #{root_dir}/#{project_name}/test/default_test.rb"
194
+ File.open("#{root_dir}/#{project_name}/test/test_helper.rb",'w') do |test_file|
195
+ test_file.puts <<EOS
196
+ require 'test/unit'
197
+
198
+ # Add test libraries you want to use here, e.g. mocha
199
+
200
+ class Test::Unit::TestCase
201
+
202
+ # Add global extensions to the test case class here
203
+
204
+ end
205
+ EOS
206
+ end
207
+ puts "Created #{root_dir}/#{project_name}/test/test_helper.rb"
136
208
  else
137
209
  file.puts "task :default => :package\n"
138
210
  end
@@ -143,6 +215,54 @@ EOS
143
215
  bundler_file.puts "gemspec"
144
216
  end
145
217
  puts "Created #{root_dir}/#{project_name}/Gemfile"
218
+ if create_test_dir
219
+ features_dir = File.join(root_dir,project_name,'features')
220
+ FileUtils.mkdir features_dir
221
+ FileUtils.mkdir File.join(features_dir,"step_definitions")
222
+ FileUtils.mkdir File.join(features_dir,"support")
223
+ File.open(File.join(features_dir,"#{project_name}.feature"),'w') do |file|
224
+ file.puts <<EOS
225
+ Feature: My bootstrapped app kinda works
226
+ In order to get going on coding my awesome app
227
+ I want to have aruba and cucumber setup
228
+ So I don't have to do it myself
229
+
230
+ Scenario: App just runs
231
+ When I get help for "#{project_name}"
232
+ Then the exit status should be 0
233
+ EOS
234
+ end
235
+ File.open(File.join(features_dir,"step_definitions","#{project_name}_steps.rb"),'w') do |file|
236
+ file.puts <<EOS
237
+ When /^I get help for "([^"]*)"$/ do |app_name|
238
+ @app_name = app_name
239
+ step %(I run `\#{app_name} help`)
240
+ end
241
+
242
+ # Add more step definitions here
243
+ EOS
244
+ end
245
+ File.open(File.join(features_dir,"support","env.rb"),'w') do |file|
246
+ file.puts <<EOS
247
+ require 'aruba/cucumber'
248
+
249
+ ENV['PATH'] = "\#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}\#{File::PATH_SEPARATOR}\#{ENV['PATH']}"
250
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
251
+
252
+ Before do
253
+ # Using "announce" causes massive warnings on 1.9.2
254
+ @puts = true
255
+ @original_rubylib = ENV['RUBYLIB']
256
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
257
+ end
258
+
259
+ After do
260
+ ENV['RUBYLIB'] = @original_rubylib
261
+ end
262
+ EOS
263
+ end
264
+ puts "Created #{features_dir}"
265
+ end
146
266
  end
147
267
 
148
268
  def self.mk_binfile(root_dir,create_ext_dir,force,dry_run,project_name,commands)
@@ -153,26 +273,18 @@ EOS
153
273
  file.chmod(0755)
154
274
  file.puts '#!/usr/bin/env ruby'
155
275
  file.puts <<EOS
156
- # 1.9 adds realpath to resolve symlinks; 1.8 doesn't
157
- # have this method, so we add it so we get resolved symlinks
158
- # and compatibility
159
- unless File.respond_to? :realpath
160
- class File #:nodoc:
161
- def self.realpath path
162
- return realpath(File.readlink(path)) if symlink?(path)
163
- path
164
- end
165
- end
166
- end
167
- EOS
168
- file.puts '$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + \'/../lib\')'
169
- file.puts '$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + \'/../ext\')' if create_ext_dir
170
- file.puts <<EOS
171
276
  require 'rubygems'
172
277
  require 'gli'
173
- require '#{project_name}_version'
278
+ begin # XXX: Remove this begin/rescue before distributing your app
279
+ require '#{project_name}'
280
+ rescue LoadError
281
+ STDERR.puts "In development, you need to use `bundle exec bin/todo` to run your app"
282
+ STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
283
+ STDERR.puts "Feel free to remove this message from bin/todo now"
284
+ exit 64
285
+ end
174
286
 
175
- include GLI
287
+ include GLI::App
176
288
 
177
289
  program_desc 'Describe your application here'
178
290
 
@@ -208,6 +320,8 @@ command :#{command} do |c|
208
320
 
209
321
  # If you have any errors, just raise them
210
322
  # raise "that command made no sense"
323
+
324
+ puts "#{command} command ran"
211
325
  end
212
326
  end
213
327
  EOS
@@ -215,6 +329,7 @@ EOS
215
329
  file.puts <<EOS
216
330
  command :#{command} do |c|
217
331
  c.action do |global_options,options,args|
332
+ puts "#{command} command ran"
218
333
  end
219
334
  end
220
335
  EOS
@@ -225,7 +340,7 @@ EOS
225
340
 
226
341
  pre do |global,command,options,args|
227
342
  # Pre logic here
228
- # Return true to proceed; false to abort and not call the
343
+ # Return true to proceed; false to abourt and not call the
229
344
  # chosen command
230
345
  # Use skips_pre before a command to skip this block
231
346
  # on that command only
@@ -244,7 +359,7 @@ on_error do |exception|
244
359
  true
245
360
  end
246
361
 
247
- exit GLI.run(ARGV)
362
+ exit run(ARGV)
248
363
  EOS
249
364
  puts "Created #{bin_file}"
250
365
  end
@@ -284,3 +399,4 @@ EOS
284
399
 
285
400
  end
286
401
  end
402
+ end