gli 2.18.2 → 2.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +28 -0
- data/.gitignore +1 -3
- data/.tool-versions +1 -1
- data/Gemfile +0 -6
- data/README.rdoc +33 -23
- data/Rakefile +21 -37
- data/bin/ci +29 -0
- data/bin/gli +25 -64
- data/bin/rake +29 -0
- data/bin/setup +5 -0
- data/exe/gli +68 -0
- data/gli.gemspec +19 -22
- data/gli.rdoc +2 -2
- data/lib/gli/command_support.rb +2 -6
- data/lib/gli/commands/help_modules/arg_name_formatter.rb +2 -2
- data/lib/gli/commands/help_modules/command_help_format.rb +1 -1
- data/lib/gli/commands/help_modules/global_help_format.rb +1 -1
- data/lib/gli/commands/scaffold.rb +9 -93
- data/lib/gli/dsl.rb +1 -1
- data/lib/gli/options.rb +2 -2
- data/lib/gli/version.rb +1 -1
- data/object-model.dot +29 -0
- data/object-model.png +0 -0
- data/test/apps/todo/Gemfile +1 -1
- data/test/apps/todo/bin/todo +1 -1
- data/test/integration/gli_cli_test.rb +69 -0
- data/test/integration/gli_powered_app_test.rb +52 -0
- data/test/integration/scaffold_test.rb +30 -0
- data/test/integration/test_helper.rb +52 -0
- data/test/{tc_command_finder.rb → unit/command_finder_test.rb} +6 -6
- data/test/{tc_command.rb → unit/command_test.rb} +4 -4
- data/test/unit/compound_command_test.rb +17 -0
- data/test/{tc_doc.rb → unit/doc_test.rb} +38 -51
- data/test/{tc_flag.rb → unit/flag_test.rb} +19 -25
- data/test/{tc_gli.rb → unit/gli_test.rb} +28 -47
- data/test/{tc_help.rb → unit/help_test.rb} +48 -107
- data/test/{init_simplecov.rb → unit/init_simplecov.rb} +0 -0
- data/test/{tc_options.rb → unit/options_test.rb} +4 -4
- data/test/unit/subcommand_parsing_test.rb +263 -0
- data/test/unit/subcommands_test.rb +245 -0
- data/test/{fake_std_out.rb → unit/support/fake_std_out.rb} +0 -0
- data/test/{config.yaml → unit/support/gli_test_config.yml} +0 -0
- data/test/unit/switch_test.rb +49 -0
- data/test/{tc_terminal.rb → unit/terminal_test.rb} +4 -3
- data/test/unit/test_helper.rb +13 -0
- data/test/unit/verbatim_wrapper_test.rb +24 -0
- metadata +74 -139
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -11
- data/ObjectModel.graffle +0 -1191
- data/bin/report_on_rake_results +0 -10
- data/bin/test_all_rubies.sh +0 -6
- data/features/gli_executable.feature +0 -90
- data/features/gli_init.feature +0 -235
- data/features/step_definitions/gli_executable_steps.rb +0 -18
- data/features/step_definitions/gli_init_steps.rb +0 -11
- data/features/step_definitions/todo_steps.rb +0 -100
- data/features/support/env.rb +0 -54
- data/features/todo.feature +0 -579
- data/features/todo_legacy.feature +0 -130
- data/test/option_test_helper.rb +0 -13
- data/test/tc_compound_command.rb +0 -22
- data/test/tc_subcommand_parsing.rb +0 -280
- data/test/tc_subcommands.rb +0 -259
- data/test/tc_switch.rb +0 -55
- data/test/tc_verbatim_wrapper.rb +0 -36
- data/test/test_helper.rb +0 -21
data/gli.gemspec
CHANGED
@@ -1,33 +1,30 @@
|
|
1
1
|
# Make sure we get the gli that's local
|
2
|
-
require File.join([File.dirname(__FILE__),
|
2
|
+
require File.join([File.dirname(__FILE__),"lib","gli","version.rb"])
|
3
3
|
|
4
4
|
spec = Gem::Specification.new do |s|
|
5
|
-
s.name =
|
5
|
+
s.name = "gli"
|
6
6
|
s.version = GLI::VERSION
|
7
|
-
s.licenses = [
|
8
|
-
s.author =
|
9
|
-
s.email =
|
10
|
-
s.homepage =
|
7
|
+
s.licenses = ["Apache-2.0"]
|
8
|
+
s.author = "David Copeland"
|
9
|
+
s.email = "davidcopeland@naildrivin5.com"
|
10
|
+
s.homepage = "http://davetron5000.github.io/gli"
|
11
11
|
s.platform = Gem::Platform::RUBY
|
12
|
-
s.summary =
|
13
|
-
s.description =
|
12
|
+
s.summary = "Build command-suite CLI apps that are awesome."
|
13
|
+
s.description = "Build command-suite CLI apps that are awesome. Bootstrap your app, add commands, options and documentation while maintaining a well-tested idiomatic command-line app"
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
-
s.executables = 'gli'
|
18
17
|
s.require_paths = ["lib"]
|
19
18
|
|
20
|
-
s.extra_rdoc_files = [
|
21
|
-
s.rdoc_options <<
|
22
|
-
|
23
|
-
s.
|
24
|
-
s.
|
25
|
-
|
26
|
-
s.add_development_dependency(
|
27
|
-
s.add_development_dependency(
|
28
|
-
s.add_development_dependency(
|
29
|
-
s.add_development_dependency(
|
30
|
-
s.add_development_dependency(
|
31
|
-
s.add_development_dependency('sdoc', '~> 0.4')
|
32
|
-
s.add_development_dependency('faker','~> 1.9.1')
|
19
|
+
s.extra_rdoc_files = ["README.rdoc", "gli.rdoc"]
|
20
|
+
s.rdoc_options << "--title" << "Git Like Interface" << "--main" << "README.rdoc"
|
21
|
+
|
22
|
+
s.bindir = "exe"
|
23
|
+
s.executables = "gli"
|
24
|
+
|
25
|
+
s.add_development_dependency("rake")
|
26
|
+
s.add_development_dependency("rdoc")
|
27
|
+
s.add_development_dependency("rainbow", "~> 1.1", "~> 1.1.1")
|
28
|
+
s.add_development_dependency("sdoc")
|
29
|
+
s.add_development_dependency("minitest")
|
33
30
|
end
|
data/gli.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
== gli - create scaffolding for a GLI-powered application
|
2
2
|
|
3
|
-
v2.
|
3
|
+
v2.19.2
|
4
4
|
|
5
5
|
=== Global Options
|
6
6
|
=== -r|--root arg
|
@@ -43,7 +43,7 @@ List commands one per line, to assist with shell completion
|
|
43
43
|
|
44
44
|
|
45
45
|
|
46
|
-
==== Command: <tt>init|scaffold project_name [command_name]
|
46
|
+
==== Command: <tt>init|scaffold project_name [command_name]...</tt>
|
47
47
|
Create a new GLI-based project
|
48
48
|
|
49
49
|
This will create a scaffold command line project that uses GLI
|
data/lib/gli/command_support.rb
CHANGED
@@ -166,12 +166,8 @@ module GLI
|
|
166
166
|
|
167
167
|
def generate_error_action(arguments)
|
168
168
|
lambda { |global_options,options,arguments|
|
169
|
-
if am_subcommand?
|
170
|
-
|
171
|
-
raise UnknownCommand,"Unknown command '#{arguments[0]}'"
|
172
|
-
else
|
173
|
-
raise BadCommandLine,"Command '#{name}' requires a subcommand"
|
174
|
-
end
|
169
|
+
if am_subcommand? && arguments.size > 0
|
170
|
+
raise UnknownCommand,"Unknown command '#{arguments[0]}'"
|
175
171
|
elsif have_subcommands?
|
176
172
|
raise BadCommandLine,"Command '#{name}' requires a subcommand #{self.commands.keys.join(',')}"
|
177
173
|
else
|
@@ -22,7 +22,7 @@ module GLI
|
|
22
22
|
arg_desc = "[#{arg_desc}]"
|
23
23
|
end
|
24
24
|
if arg.multiple?
|
25
|
-
arg_desc = "#{arg_desc}
|
25
|
+
arg_desc = "#{arg_desc}..."
|
26
26
|
end
|
27
27
|
desc = desc + " " + arg_desc
|
28
28
|
end
|
@@ -37,7 +37,7 @@ module GLI
|
|
37
37
|
desc = "[#{desc}]"
|
38
38
|
end
|
39
39
|
if arguments_options.include? :multiple
|
40
|
-
desc = "#{desc}
|
40
|
+
desc = "#{desc}..."
|
41
41
|
end
|
42
42
|
" " + desc
|
43
43
|
end
|
@@ -70,10 +70,10 @@ spec = Gem::Specification.new do |s|
|
|
70
70
|
s.rdoc_options << '--title' << '#{project_name}' << '--main' << 'README.rdoc' << '-ri'
|
71
71
|
s.bindir = 'bin'
|
72
72
|
s.executables << '#{project_name}'
|
73
|
-
s.add_development_dependency('rake')
|
74
|
-
s.add_development_dependency('rdoc')
|
75
|
-
s.add_development_dependency('
|
76
|
-
s.add_runtime_dependency('gli','#{GLI::VERSION}')
|
73
|
+
s.add_development_dependency('rake','~> 0.9.2')
|
74
|
+
s.add_development_dependency('rdoc', '~> 4.3')
|
75
|
+
s.add_development_dependency('minitest', '~> 5.14')
|
76
|
+
s.add_runtime_dependency('gli','~> #{GLI::VERSION}')
|
77
77
|
end
|
78
78
|
EOS
|
79
79
|
end
|
@@ -114,12 +114,6 @@ require 'rubygems'
|
|
114
114
|
require 'rubygems/package_task'
|
115
115
|
require 'rdoc/task'
|
116
116
|
EOS
|
117
|
-
if create_test_dir
|
118
|
-
file.puts <<EOS
|
119
|
-
require 'cucumber'
|
120
|
-
require 'cucumber/rake/task'
|
121
|
-
EOS
|
122
|
-
end
|
123
117
|
file.puts <<EOS
|
124
118
|
Rake::RDocTask.new do |rd|
|
125
119
|
rd.main = "README.rdoc"
|
@@ -134,44 +128,19 @@ end
|
|
134
128
|
EOS
|
135
129
|
if create_test_dir
|
136
130
|
file.puts <<EOS
|
137
|
-
CUKE_RESULTS = 'results.html'
|
138
|
-
CLEAN << CUKE_RESULTS
|
139
|
-
desc 'Run features'
|
140
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
141
|
-
opts = "features --format html -o \#{CUKE_RESULTS} --format progress -x"
|
142
|
-
opts += " --tags \#{ENV['TAGS']}" if ENV['TAGS']
|
143
|
-
t.cucumber_opts = opts
|
144
|
-
t.fork = false
|
145
|
-
end
|
146
|
-
|
147
|
-
desc 'Run features tagged as work-in-progress (@wip)'
|
148
|
-
Cucumber::Rake::Task.new('features:wip') do |t|
|
149
|
-
tag_opts = ' --tags ~@pending'
|
150
|
-
tag_opts = ' --tags @wip'
|
151
|
-
t.cucumber_opts = "features --format html -o \#{CUKE_RESULTS} --format pretty -x -s\#{tag_opts}"
|
152
|
-
t.fork = false
|
153
|
-
end
|
154
|
-
|
155
|
-
task :cucumber => :features
|
156
|
-
task 'cucumber:wip' => 'features:wip'
|
157
|
-
task :wip => 'features:wip'
|
158
|
-
EOS
|
159
|
-
end
|
160
|
-
if create_test_dir
|
161
|
-
file.puts <<EOS
|
162
131
|
require 'rake/testtask'
|
163
132
|
Rake::TestTask.new do |t|
|
164
133
|
t.libs << "test"
|
165
134
|
t.test_files = FileList['test/*_test.rb']
|
166
135
|
end
|
167
136
|
|
168
|
-
task :default =>
|
137
|
+
task :default => :test
|
169
138
|
EOS
|
170
139
|
File.open("#{root_dir}/#{project_name}/test/default_test.rb",'w') do |test_file|
|
171
140
|
test_file.puts <<EOS
|
172
|
-
|
141
|
+
require_relative "test_helper"
|
173
142
|
|
174
|
-
class DefaultTest < Test
|
143
|
+
class DefaultTest < Minitest::Test
|
175
144
|
|
176
145
|
def setup
|
177
146
|
end
|
@@ -188,15 +157,10 @@ EOS
|
|
188
157
|
puts "Created #{root_dir}/#{project_name}/test/default_test.rb"
|
189
158
|
File.open("#{root_dir}/#{project_name}/test/test_helper.rb",'w') do |test_file|
|
190
159
|
test_file.puts <<EOS
|
191
|
-
require
|
160
|
+
require "minitest/autorun"
|
192
161
|
|
193
162
|
# Add test libraries you want to use here, e.g. mocha
|
194
|
-
|
195
|
-
class Test::Unit::TestCase
|
196
|
-
|
197
|
-
# Add global extensions to the test case class here
|
198
|
-
|
199
|
-
end
|
163
|
+
# Add helper classes or methods here, too
|
200
164
|
EOS
|
201
165
|
end
|
202
166
|
puts "Created #{root_dir}/#{project_name}/test/test_helper.rb"
|
@@ -210,54 +174,6 @@ EOS
|
|
210
174
|
bundler_file.puts "gemspec"
|
211
175
|
end
|
212
176
|
puts "Created #{root_dir}/#{project_name}/Gemfile"
|
213
|
-
if create_test_dir
|
214
|
-
features_dir = File.join(root_dir,project_name,'features')
|
215
|
-
FileUtils.mkdir features_dir
|
216
|
-
FileUtils.mkdir File.join(features_dir,"step_definitions")
|
217
|
-
FileUtils.mkdir File.join(features_dir,"support")
|
218
|
-
File.open(File.join(features_dir,"#{project_name}.feature"),'w') do |file|
|
219
|
-
file.puts <<EOS
|
220
|
-
Feature: My bootstrapped app kinda works
|
221
|
-
In order to get going on coding my awesome app
|
222
|
-
I want to have aruba and cucumber setup
|
223
|
-
So I don't have to do it myself
|
224
|
-
|
225
|
-
Scenario: App just runs
|
226
|
-
When I get help for "#{project_name}"
|
227
|
-
Then the exit status should be 0
|
228
|
-
EOS
|
229
|
-
end
|
230
|
-
File.open(File.join(features_dir,"step_definitions","#{project_name}_steps.rb"),'w') do |file|
|
231
|
-
file.puts <<EOS
|
232
|
-
When /^I get help for "([^"]*)"$/ do |app_name|
|
233
|
-
@app_name = app_name
|
234
|
-
step %(I run `\#{app_name} help`)
|
235
|
-
end
|
236
|
-
|
237
|
-
# Add more step definitions here
|
238
|
-
EOS
|
239
|
-
end
|
240
|
-
File.open(File.join(features_dir,"support","env.rb"),'w') do |file|
|
241
|
-
file.puts <<EOS
|
242
|
-
require 'aruba/cucumber'
|
243
|
-
|
244
|
-
ENV['PATH'] = "\#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}\#{File::PATH_SEPARATOR}\#{ENV['PATH']}"
|
245
|
-
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
246
|
-
|
247
|
-
Before do
|
248
|
-
# Using "announce" causes massive warnings on 1.9.2
|
249
|
-
@puts = true
|
250
|
-
@original_rubylib = ENV['RUBYLIB']
|
251
|
-
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
252
|
-
end
|
253
|
-
|
254
|
-
After do
|
255
|
-
ENV['RUBYLIB'] = @original_rubylib
|
256
|
-
end
|
257
|
-
EOS
|
258
|
-
end
|
259
|
-
puts "Created #{features_dir}"
|
260
|
-
end
|
261
177
|
end
|
262
178
|
|
263
179
|
def self.mk_binfile(root_dir,create_ext_dir,force,dry_run,project_name,commands)
|
data/lib/gli/dsl.rb
CHANGED
@@ -50,7 +50,7 @@ module GLI
|
|
50
50
|
# command :pack do ...
|
51
51
|
#
|
52
52
|
# Produces the synopsis:
|
53
|
-
# app.rb [global options] pack output input
|
53
|
+
# app.rb [global options] pack output input...
|
54
54
|
def arg(name, options=[])
|
55
55
|
@next_arguments ||= []
|
56
56
|
@next_arguments << Argument.new(name, Array(options).flatten)
|
data/lib/gli/options.rb
CHANGED
@@ -7,12 +7,12 @@ module GLI
|
|
7
7
|
|
8
8
|
# Return the value of an attribute
|
9
9
|
def[](k)
|
10
|
-
|
10
|
+
self.send(k.to_sym)
|
11
11
|
end
|
12
12
|
|
13
13
|
# Set the value of an attribute
|
14
14
|
def[]=(k, v)
|
15
|
-
|
15
|
+
self.send("#{k.to_sym}=",v)
|
16
16
|
end
|
17
17
|
|
18
18
|
def map(&block)
|
data/lib/gli/version.rb
CHANGED
data/object-model.dot
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
digraph G {
|
2
|
+
|
3
|
+
rankdir="BT"
|
4
|
+
nodesep=0.5
|
5
|
+
|
6
|
+
node[shape=record fontname=courier fontsize=18]
|
7
|
+
edge[fontname=avenir fontsize=12]
|
8
|
+
|
9
|
+
CommandLineToken [ label="{ CommandLineToken | #name\l | #description\l | #long_description\l | #aliases\l}"]
|
10
|
+
CommandLineOption [ label="{ CommandLineOption | #default_value \l }"]
|
11
|
+
DSL
|
12
|
+
Command
|
13
|
+
Flag [ label="{ Flag | #argument_name\l }"]
|
14
|
+
Switch
|
15
|
+
App
|
16
|
+
TopLevel [ label="top level?" shape=diamond fontname=avenir fontsize=12]
|
17
|
+
|
18
|
+
Command -> DSL [ arrowhead=oarrow label=" includes" minlen=3]
|
19
|
+
Command -> CommandLineToken [ arrowhead=oarrow label="inherits"]
|
20
|
+
CommandLineOption -> CommandLineToken [ arrowhead=oarrow label="inherits"]
|
21
|
+
Flag -> CommandLineOption [ arrowhead=oarrow label="inherits"]
|
22
|
+
Switch -> CommandLineOption [ arrowhead=oarrow label="inherits"]
|
23
|
+
Command -> TopLevel [ arrowhead=none label="parent" style=dotted]
|
24
|
+
TopLevel -> App [ arrowhead=odiamond label="YES" style=dotted ]
|
25
|
+
TopLevel -> Command [ arrowhead=odiamond label="NO" style=dotted ]
|
26
|
+
CommandLineOption -> Command [ arrowhead=odiamond style=dotted label="associated_command"]
|
27
|
+
|
28
|
+
{ rank=same; DSL; App }
|
29
|
+
}
|
data/object-model.png
ADDED
Binary file
|
data/test/apps/todo/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/test/apps/todo/bin/todo
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# These would not be in a real GLI app; we do this so we can easily run this on the command line
|
4
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','lib'))
|
4
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','..','lib'))
|
5
5
|
$: << File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
|
6
6
|
|
7
7
|
require 'gli'
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
require "open3"
|
3
|
+
|
4
|
+
class GLICLITest < MiniTest::Test
|
5
|
+
include TestHelper
|
6
|
+
|
7
|
+
class AppHelp < GLICLITest
|
8
|
+
def test_running_with_no_options_produces_help
|
9
|
+
out = run_gli
|
10
|
+
assert_output_looks_like_help out
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_running_with_help_command_produces_help
|
14
|
+
out = run_gli("help")
|
15
|
+
assert_output_looks_like_help out
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_running_with_help_switch_produces_help
|
19
|
+
out = run_gli("--help")
|
20
|
+
assert_output_looks_like_help out
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def assert_output_looks_like_help(out)
|
26
|
+
assert_match /gli - create scaffolding for a GLI-powered application/,out
|
27
|
+
assert_match /SYNOPSIS/,out
|
28
|
+
assert_match /GLOBAL OPTIONS/,out
|
29
|
+
assert_match /COMMANDS/,out
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
class Scaffolding < GLICLITest
|
35
|
+
def test_help_on_scaffold_command
|
36
|
+
out = run_gli("help scaffold")
|
37
|
+
assert_output_looks_like_help(out)
|
38
|
+
end
|
39
|
+
def test_help_on_scaffold_command_as_init
|
40
|
+
out = run_gli("help init")
|
41
|
+
assert_output_looks_like_help(out)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def assert_output_looks_like_help(out)
|
47
|
+
assert_match /init - Create a new GLI-based project/,out
|
48
|
+
assert_match /SYNOPSIS/,out
|
49
|
+
assert_match /COMMAND OPTIONS/,out
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def run_gli(args="", return_err_and_status: false, expect_failure: false)
|
56
|
+
command_line_invocation = "bin/gli #{args}"
|
57
|
+
stdout_string, stderr_string, status = Open3.capture3(command_line_invocation)
|
58
|
+
if expect_failure
|
59
|
+
refute_equal 0,status.exitstatus,"Expected failure for '#{command_line_invocation}' but it succeeded"
|
60
|
+
else
|
61
|
+
assert_equal 0,status.exitstatus,"Expected success for '#{command_line_invocation}' but it failed"
|
62
|
+
end
|
63
|
+
if return_err_and_status
|
64
|
+
[ stdout_string, stderr_string, status ]
|
65
|
+
else
|
66
|
+
stdout_string
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
require "open3"
|
3
|
+
|
4
|
+
class GLIPoweredAppTest < MiniTest::Test
|
5
|
+
include TestHelper
|
6
|
+
|
7
|
+
def teardown
|
8
|
+
FileUtils.rm_f("todo.rdoc")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_help_works
|
12
|
+
out = run_app("help")
|
13
|
+
assert_top_level_help(out)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_unknown_command_exits_nonzero
|
17
|
+
out, err, status = run_app("asdfasdfasdf", expect_failure: true, return_err_and_status: true)
|
18
|
+
assert_match /Unknown command 'asdfasdfasdf'/,err
|
19
|
+
assert_equal 64, status.exitstatus
|
20
|
+
assert_top_level_help(out)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_unknown_switch_exits_nonzero
|
24
|
+
out, err, status = run_app("list --foo", expect_failure: true, return_err_and_status: true)
|
25
|
+
assert_match /Unknown option \-\-foo/,err
|
26
|
+
assert_equal 64, status.exitstatus
|
27
|
+
assert_match /COMMAND OPTIONS/, out
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_missing_args_exits_nonzero
|
31
|
+
out, err, status = run_app("list", expect_failure: true, return_err_and_status: true)
|
32
|
+
assert_match /required_flag is required, required_flag2 is required/,err
|
33
|
+
assert_equal 64, status.exitstatus
|
34
|
+
assert_match /COMMAND OPTIONS/, out
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_doc_generation
|
38
|
+
out, err, status = run_app("_doc", return_err_and_status: true)
|
39
|
+
assert File.exists?("todo.rdoc")
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def assert_top_level_help(out)
|
44
|
+
assert_match /SYNOPSIS/, out
|
45
|
+
assert_match /GLOBAL OPTIONS/, out
|
46
|
+
assert_match /COMMANDS/, out
|
47
|
+
end
|
48
|
+
|
49
|
+
def run_app(args="", return_err_and_status: false, expect_failure: false)
|
50
|
+
run_command("test/apps/todo/bin/todo",args,return_err_and_status:return_err_and_status,expect_failure:expect_failure)
|
51
|
+
end
|
52
|
+
end
|