gli 2.9.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +28 -0
- data/.gitignore +3 -3
- data/.tool-versions +1 -0
- data/Gemfile +0 -2
- data/README.rdoc +29 -18
- data/Rakefile +15 -37
- data/bin/ci +29 -0
- data/bin/gli +24 -54
- data/bin/rake +29 -0
- data/bin/setup +5 -0
- data/exe/gli +68 -0
- data/gli.gemspec +20 -24
- data/gli.rdoc +9 -9
- data/lib/gli/app.rb +42 -8
- data/lib/gli/app_support.rb +17 -5
- data/lib/gli/argument.rb +20 -0
- data/lib/gli/command.rb +27 -2
- data/lib/gli/command_finder.rb +42 -25
- data/lib/gli/command_support.rb +13 -7
- data/lib/gli/commands/doc.rb +9 -3
- data/lib/gli/commands/help.rb +2 -1
- data/lib/gli/commands/help_modules/arg_name_formatter.rb +29 -2
- data/lib/gli/commands/help_modules/command_help_format.rb +19 -1
- data/lib/gli/commands/help_modules/full_synopsis_formatter.rb +5 -4
- data/lib/gli/commands/help_modules/global_help_format.rb +1 -1
- data/lib/gli/commands/help_modules/options_formatter.rb +4 -6
- data/lib/gli/commands/initconfig.rb +3 -6
- data/lib/gli/commands/rdoc_document_listener.rb +2 -1
- data/lib/gli/commands/scaffold.rb +71 -142
- data/lib/gli/dsl.rb +25 -1
- data/lib/gli/exceptions.rb +26 -0
- data/lib/gli/flag.rb +23 -2
- data/lib/gli/gli_option_parser.rb +73 -21
- data/lib/gli/option_parser_factory.rb +10 -3
- data/lib/gli/options.rb +2 -2
- data/lib/gli/switch.rb +4 -0
- data/lib/gli/terminal.rb +6 -2
- data/lib/gli/version.rb +1 -1
- data/lib/gli.rb +2 -0
- 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 +16 -6
- data/test/apps/todo/lib/todo/commands/create.rb +48 -18
- data/test/apps/todo/lib/todo/commands/list.rb +48 -35
- data/test/apps/todo/lib/todo/commands/ls.rb +25 -24
- data/test/apps/todo/lib/todo/commands/make.rb +42 -39
- data/test/apps/todo/todo.gemspec +1 -2
- data/test/apps/todo_legacy/todo.gemspec +1 -2
- data/test/apps/todo_plugins/commands/third.rb +2 -0
- 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/unit/command_finder_test.rb +54 -0
- data/test/{tc_command.rb → unit/command_test.rb} +20 -7
- 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} +92 -49
- data/test/{tc_help.rb → unit/help_test.rb} +54 -113
- 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} +1 -0
- data/test/unit/switch_test.rb +49 -0
- data/test/{tc_terminal.rb → unit/terminal_test.rb} +28 -3
- data/test/unit/test_helper.rb +13 -0
- data/test/unit/verbatim_wrapper_test.rb +24 -0
- metadata +86 -141
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -12
- 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 -232
- 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 -96
- data/features/support/env.rb +0 -54
- data/features/todo.feature +0 -449
- data/features/todo_legacy.feature +0 -128
- data/test/option_test_helper.rb +0 -13
- data/test/tc_compound_command.rb +0 -22
- data/test/tc_subcommand_parsing.rb +0 -104
- 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 -20
data/bin/report_on_rake_results
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'yaml'
|
3
|
-
require 'rainbow'
|
4
|
-
|
5
|
-
results = YAML::load(STDIN)
|
6
|
-
success = results["successes"] || []
|
7
|
-
errors = results["errors"] || []
|
8
|
-
success.each { |ruby| puts ruby.color(:green) }
|
9
|
-
errors.each { |ruby| puts ruby.color(:red) }
|
10
|
-
exit -1 unless errors.empty?
|
data/bin/test_all_rubies.sh
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
echo tests
|
2
|
-
rvm 1.9.2@gli-dev,1.9.3@gli-dev,1.8.7@gli-dev,jruby@gli-dev,rbx@gli-dev,ree@gli-dev --yaml rake test | bin/report_on_rake_results
|
3
|
-
rake clobber > /dev/null 2>&1
|
4
|
-
echo features
|
5
|
-
rvm 1.9.2@gli-dev,1.9.3@gli-dev,1.8.7@gli-dev,jruby@gli-dev,rbx@gli-dev,ree@gli-dev --yaml rake features | bin/report_on_rake_results
|
6
|
-
rake clobber > /dev/null 2>&1
|
@@ -1,90 +0,0 @@
|
|
1
|
-
Feature: The GLI executable works as intended
|
2
|
-
As a developer who wants to make a GLI-powered command-line app
|
3
|
-
When I use the app provided by GLI
|
4
|
-
I get a reasonably working application
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given I have GLI installed
|
8
|
-
And my terminal size is "80x24"
|
9
|
-
|
10
|
-
Scenario Outline: Getting Help for GLI
|
11
|
-
When I run `gli <command>`
|
12
|
-
Then the exit status should be 0
|
13
|
-
And the output should contain:
|
14
|
-
"""
|
15
|
-
NAME
|
16
|
-
gli - create scaffolding for a GLI-powered application
|
17
|
-
|
18
|
-
SYNOPSIS
|
19
|
-
gli [global options] command [command options] [arguments...]
|
20
|
-
|
21
|
-
VERSION
|
22
|
-
"""
|
23
|
-
And the output should contain:
|
24
|
-
"""
|
25
|
-
GLOBAL OPTIONS
|
26
|
-
--help - Show this message
|
27
|
-
-n - Dry run; dont change the disk
|
28
|
-
-r, --root=arg - Root dir of project (default: .)
|
29
|
-
-v - Be verbose
|
30
|
-
--version - Display the program version
|
31
|
-
|
32
|
-
COMMANDS
|
33
|
-
help - Shows a list of commands or help for one command
|
34
|
-
init, scaffold - Create a new GLI-based project
|
35
|
-
"""
|
36
|
-
|
37
|
-
Examples:
|
38
|
-
|command|
|
39
|
-
| |
|
40
|
-
|help |
|
41
|
-
|
42
|
-
|
43
|
-
Scenario Outline: Getting help on scaffolding
|
44
|
-
When I run `gli help <command>`
|
45
|
-
Then the exit status should be 0
|
46
|
-
And the output should contain:
|
47
|
-
"""
|
48
|
-
NAME
|
49
|
-
init - Create a new GLI-based project
|
50
|
-
|
51
|
-
SYNOPSIS
|
52
|
-
gli [global options] init [command options] project_name [command[ command]*]
|
53
|
-
|
54
|
-
DESCRIPTION
|
55
|
-
This will create a scaffold command line project that uses GLI for command
|
56
|
-
line processing. Specifically, this will create an executable ready to go,
|
57
|
-
as well as a lib and test directory, all inside the directory named for your
|
58
|
-
project
|
59
|
-
|
60
|
-
COMMAND OPTIONS
|
61
|
-
-e, --[no-]ext - Create an ext dir
|
62
|
-
--[no-]force - Overwrite/ignore existing files and directories
|
63
|
-
--notest - Do not create a test or features dir
|
64
|
-
"""
|
65
|
-
|
66
|
-
Examples:
|
67
|
-
|command |
|
68
|
-
|init |
|
69
|
-
|scaffold |
|
70
|
-
|
71
|
-
|
72
|
-
Scenario: GLI correctly identifies non-existent command
|
73
|
-
When I run `gli foobar`
|
74
|
-
Then the exit status should not be 0
|
75
|
-
And the stderr should contain "error: Unknown command 'foobar'"
|
76
|
-
|
77
|
-
Scenario: GLI correctly identifies non-existent global flag
|
78
|
-
When I run `gli -q help`
|
79
|
-
Then the exit status should not be 0
|
80
|
-
And the stderr should contain "error: Unknown option -q"
|
81
|
-
|
82
|
-
Scenario: GLI correctly identifies non-existent command flag
|
83
|
-
When I run `gli init -q`
|
84
|
-
Then the exit status should not be 0
|
85
|
-
And the stderr should contain "error: Unknown option -q"
|
86
|
-
|
87
|
-
Scenario: The _doc command doesn't blow up
|
88
|
-
Given the file "gli.rdoc" doesn't exist
|
89
|
-
When I run `gli _doc`
|
90
|
-
Then a file named "gli.rdoc" should exist
|
data/features/gli_init.feature
DELETED
@@ -1,232 +0,0 @@
|
|
1
|
-
Feature: The scaffold GLI generates works
|
2
|
-
As a developer who wants to make a GLI-powered command-line app
|
3
|
-
When I generate a GLI-powered app
|
4
|
-
Things work out of the box
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given I have GLI installed
|
8
|
-
And GLI's libs are in my path
|
9
|
-
And my terminal size is "80x24"
|
10
|
-
|
11
|
-
Scenario: Scaffold generates and things look good
|
12
|
-
When I run `gli init --rvmrc todo add complete list`
|
13
|
-
Then the exit status should be 0
|
14
|
-
And the output should contain exactly:
|
15
|
-
"""
|
16
|
-
Creating dir ./todo/lib...
|
17
|
-
Creating dir ./todo/bin...
|
18
|
-
Creating dir ./todo/test...
|
19
|
-
Created ./todo/bin/todo
|
20
|
-
Created ./todo/README.rdoc
|
21
|
-
Created ./todo/todo.rdoc
|
22
|
-
Created ./todo/todo.gemspec
|
23
|
-
Created ./todo/test/default_test.rb
|
24
|
-
Created ./todo/test/test_helper.rb
|
25
|
-
Created ./todo/Rakefile
|
26
|
-
Created ./todo/Gemfile
|
27
|
-
Created ./todo/features
|
28
|
-
Created ./todo/lib/todo/version.rb
|
29
|
-
Created ./todo/lib/todo.rb
|
30
|
-
Created ./todo/.rvmrc
|
31
|
-
|
32
|
-
"""
|
33
|
-
And the following directories should exist:
|
34
|
-
|todo |
|
35
|
-
|todo/bin |
|
36
|
-
|todo/test |
|
37
|
-
|todo/lib |
|
38
|
-
And the following files should exist:
|
39
|
-
|todo/bin/todo |
|
40
|
-
|todo/README.rdoc |
|
41
|
-
|todo/todo.rdoc |
|
42
|
-
|todo/todo.gemspec |
|
43
|
-
|todo/test/default_test.rb |
|
44
|
-
|todo/test/test_helper.rb |
|
45
|
-
|todo/Rakefile |
|
46
|
-
|todo/Gemfile |
|
47
|
-
|todo/lib/todo/version.rb |
|
48
|
-
|todo/lib/todo.rb |
|
49
|
-
|todo/.rvmrc |
|
50
|
-
When I cd to "todo"
|
51
|
-
And I make sure todo's lib dir is in my lib path
|
52
|
-
And I run `bin/todo`
|
53
|
-
Then the output should contain:
|
54
|
-
"""
|
55
|
-
NAME
|
56
|
-
todo - Describe your application here
|
57
|
-
|
58
|
-
SYNOPSIS
|
59
|
-
todo [global options] command [command options] [arguments...]
|
60
|
-
|
61
|
-
VERSION
|
62
|
-
0.0.1
|
63
|
-
|
64
|
-
GLOBAL OPTIONS
|
65
|
-
-f, --flagname=The name of the argument - Describe some flag here (default:
|
66
|
-
the default)
|
67
|
-
--help - Show this message
|
68
|
-
-s, --[no-]switch - Describe some switch here
|
69
|
-
--version - Display the program version
|
70
|
-
|
71
|
-
COMMANDS
|
72
|
-
add - Describe add here
|
73
|
-
complete - Describe complete here
|
74
|
-
help - Shows a list of commands or help for one command
|
75
|
-
list - Describe list here
|
76
|
-
|
77
|
-
"""
|
78
|
-
And I run `bin/todo --help`
|
79
|
-
Then the output should contain:
|
80
|
-
"""
|
81
|
-
NAME
|
82
|
-
todo - Describe your application here
|
83
|
-
|
84
|
-
SYNOPSIS
|
85
|
-
todo [global options] command [command options] [arguments...]
|
86
|
-
|
87
|
-
VERSION
|
88
|
-
0.0.1
|
89
|
-
|
90
|
-
GLOBAL OPTIONS
|
91
|
-
-f, --flagname=The name of the argument - Describe some flag here (default:
|
92
|
-
the default)
|
93
|
-
--help - Show this message
|
94
|
-
-s, --[no-]switch - Describe some switch here
|
95
|
-
--version - Display the program version
|
96
|
-
|
97
|
-
COMMANDS
|
98
|
-
add - Describe add here
|
99
|
-
complete - Describe complete here
|
100
|
-
help - Shows a list of commands or help for one command
|
101
|
-
list - Describe list here
|
102
|
-
|
103
|
-
"""
|
104
|
-
When I run `bin/todo help add`
|
105
|
-
Then the output should contain:
|
106
|
-
"""
|
107
|
-
NAME
|
108
|
-
add - Describe add here
|
109
|
-
"""
|
110
|
-
And the output should contain:
|
111
|
-
"""
|
112
|
-
SYNOPSIS
|
113
|
-
todo [global options] add [command options] Describe arguments to add here
|
114
|
-
"""
|
115
|
-
And the output should contain:
|
116
|
-
"""
|
117
|
-
COMMAND OPTIONS
|
118
|
-
-f arg - Describe a flag to add (default: default)
|
119
|
-
-s - Describe a switch to add
|
120
|
-
"""
|
121
|
-
When I run `rake test`
|
122
|
-
Then the output should contain:
|
123
|
-
"""
|
124
|
-
.
|
125
|
-
"""
|
126
|
-
And the output should contain:
|
127
|
-
"""
|
128
|
-
|
129
|
-
1 tests, 1 assertions, 0 failures, 0 errors
|
130
|
-
"""
|
131
|
-
Given todo's libs are no longer in my load path
|
132
|
-
When I run `rake features`
|
133
|
-
Then the output should contain:
|
134
|
-
"""
|
135
|
-
1 scenario (1 passed)
|
136
|
-
"""
|
137
|
-
And the output should contain:
|
138
|
-
"""
|
139
|
-
2 steps (2 passed)
|
140
|
-
"""
|
141
|
-
|
142
|
-
Scenario Outline: Scaffold generates and respects flags to create ext dir and avoid test dir
|
143
|
-
When I run `<command>`
|
144
|
-
Then the exit status should be 0
|
145
|
-
And the output should contain exactly:
|
146
|
-
"""
|
147
|
-
Creating dir ./todo/lib...
|
148
|
-
Creating dir ./todo/bin...
|
149
|
-
Creating dir ./todo/ext...
|
150
|
-
Created ./todo/bin/todo
|
151
|
-
Created ./todo/README.rdoc
|
152
|
-
Created ./todo/todo.rdoc
|
153
|
-
Created ./todo/todo.gemspec
|
154
|
-
Created ./todo/Rakefile
|
155
|
-
Created ./todo/Gemfile
|
156
|
-
Created ./todo/lib/todo/version.rb
|
157
|
-
Created ./todo/lib/todo.rb
|
158
|
-
|
159
|
-
"""
|
160
|
-
And the following directories should exist:
|
161
|
-
|todo |
|
162
|
-
|todo/bin |
|
163
|
-
|todo/ext |
|
164
|
-
|todo/lib |
|
165
|
-
And the following directories should not exist:
|
166
|
-
|todo/test|
|
167
|
-
And the following files should exist:
|
168
|
-
|todo/bin/todo |
|
169
|
-
|todo/README.rdoc |
|
170
|
-
|todo/todo.rdoc |
|
171
|
-
|todo/todo.gemspec |
|
172
|
-
|todo/Rakefile |
|
173
|
-
|todo/Gemfile |
|
174
|
-
|todo/lib/todo/version.rb |
|
175
|
-
|todo/lib/todo.rb |
|
176
|
-
|
177
|
-
Examples:
|
178
|
-
| command |
|
179
|
-
| gli init -e --notest todo add complete list |
|
180
|
-
| gli init todo add complete list -e --notest |
|
181
|
-
|
182
|
-
Scenario: Running commands the normal way
|
183
|
-
Given I successfully run `gli init todo add complete compute list`
|
184
|
-
And I cd to "todo"
|
185
|
-
And I make sure todo's lib dir is in my lib path
|
186
|
-
When I successfully run `bin/todo add`
|
187
|
-
Then the output should contain "add command ran"
|
188
|
-
When I successfully run `bin/todo complete`
|
189
|
-
Then the output should contain "complete command ran"
|
190
|
-
When I run `bin/todo foobar`
|
191
|
-
Then the stderr should contain "error: Unknown command 'foobar'"
|
192
|
-
And the exit status should not be 0
|
193
|
-
|
194
|
-
Scenario: Running commands using short form
|
195
|
-
Given I successfully run `gli init todo add complete compute list`
|
196
|
-
And I cd to "todo"
|
197
|
-
And I make sure todo's lib dir is in my lib path
|
198
|
-
When I successfully run `bin/todo a`
|
199
|
-
Then the output should contain "add command ran"
|
200
|
-
When I successfully run `bin/todo l`
|
201
|
-
Then the output should contain "list command ran"
|
202
|
-
When I successfully run `bin/todo compl`
|
203
|
-
Then the output should contain "complete command ran"
|
204
|
-
|
205
|
-
Scenario: Ambiguous commands give helpful output
|
206
|
-
Given I successfully run `gli init todo add complete compute list`
|
207
|
-
And I cd to "todo"
|
208
|
-
And I make sure todo's lib dir is in my lib path
|
209
|
-
When I run `bin/todo comp`
|
210
|
-
Then the stderr should contain "Ambiguous command 'comp'. It matches complete,compute"
|
211
|
-
And the exit status should not be 0
|
212
|
-
|
213
|
-
Scenario: Running generated command without bundler gives a helpful error message
|
214
|
-
Given I successfully run `gli init todo add complete compute list`
|
215
|
-
And I cd to "todo"
|
216
|
-
When I run `bin/todo comp`
|
217
|
-
Then the exit status should not be 0
|
218
|
-
Then the stderr should contain "In development, you need to use `bundle exec bin/todo` to run your app"
|
219
|
-
And the stderr should contain "At install-time, RubyGems will make sure lib, etc. are in the load path"
|
220
|
-
And the stderr should contain "Feel free to remove this message from bin/todo now"
|
221
|
-
|
222
|
-
Scenario: Running commands with a dash in the name
|
223
|
-
Given I successfully run `gli init todo-app add complete compute list`
|
224
|
-
And I cd to "todo-app"
|
225
|
-
And I make sure todo's lib dir is in my lib path
|
226
|
-
When I successfully run `bin/todo-app add`
|
227
|
-
Then the output should contain "add command ran"
|
228
|
-
When I successfully run `bin/todo-app complete`
|
229
|
-
Then the output should contain "complete command ran"
|
230
|
-
When I run `bin/todo-app foobar`
|
231
|
-
Then the stderr should contain "error: Unknown command 'foobar'"
|
232
|
-
And the exit status should not be 0
|
@@ -1,18 +0,0 @@
|
|
1
|
-
Given /^I have GLI installed$/ do
|
2
|
-
add_to_lib_path(GLI_LIB_PATH)
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /^my terminal size is "([^"]*)"$/ do |terminal_size|
|
6
|
-
if terminal_size =~/^(\d+)x(\d+)$/
|
7
|
-
ENV['COLUMNS'] = $1
|
8
|
-
ENV['LINES'] = $2
|
9
|
-
else
|
10
|
-
raise "Terminal size should be COLxLines, e.g. 80x24"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
Given /^the file "(.*?)" doesn't exist$/ do |filename|
|
16
|
-
FileUtils.rm filename if File.exists?(filename)
|
17
|
-
end
|
18
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
Given /^GLI's libs are in my path$/ do
|
2
|
-
ENV['RUBYLIB'] = GLI_LIB_PATH
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /^I make sure todo's lib dir is in my lib path$/ do
|
6
|
-
add_to_lib_path("./lib")
|
7
|
-
end
|
8
|
-
|
9
|
-
Given /^todo's libs are no longer in my load path$/ do
|
10
|
-
remove_from_lib_path("./lib")
|
11
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
Given /^todo_legacy's bin directory is in my path/ do
|
2
|
-
add_to_path(File.expand_path(File.join(File.dirname(__FILE__),'..','..','test','apps','todo_legacy','bin')))
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /^todo's bin directory is in my path/ do
|
6
|
-
add_to_path(File.expand_path(File.join(File.dirname(__FILE__),'..','..','test','apps','todo','bin')))
|
7
|
-
end
|
8
|
-
|
9
|
-
Given /^the todo app is coded to avoid sorted help commands$/ do
|
10
|
-
ENV['TODO_SORT_HELP'] = 'manually'
|
11
|
-
end
|
12
|
-
|
13
|
-
Given /^the todo app is coded to avoid wrapping text$/ do
|
14
|
-
ENV['TODO_WRAP_HELP_TEXT'] = 'one_line'
|
15
|
-
end
|
16
|
-
|
17
|
-
Given /^the todo app is coded to wrap text only for tty$/ do
|
18
|
-
ENV['TODO_WRAP_HELP_TEXT'] = 'tty_only'
|
19
|
-
end
|
20
|
-
|
21
|
-
Given /^a clean home directory$/ do
|
22
|
-
FileUtils.rm_rf File.join(ENV['HOME'],'gli_test_todo.rc')
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^the config file should contain a section for each command and subcommand$/ do
|
26
|
-
config = File.open(File.join(ENV['HOME'],'gli_test_todo.rc')) do |file|
|
27
|
-
YAML::load(file)
|
28
|
-
end
|
29
|
-
config.keys.should include(:flag)
|
30
|
-
config[:flag].should == 'foo'
|
31
|
-
config[:flag].tap do |flag|
|
32
|
-
if flag.respond_to?(:encoding)
|
33
|
-
flag.encoding.name.should == 'UTF-8'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
config.keys.should include(:switch)
|
37
|
-
config[:switch].should == true
|
38
|
-
config.keys.should include(:otherswitch)
|
39
|
-
config[:otherswitch].should == false
|
40
|
-
config.keys.should include('commands')
|
41
|
-
%w(chained chained2 create first list ls second).map(&:to_sym).each do |command_name|
|
42
|
-
config['commands'].keys.should include(command_name)
|
43
|
-
end
|
44
|
-
config['commands'][:create].keys.should include('commands')
|
45
|
-
config['commands'][:create]['commands'].should include(:tasks)
|
46
|
-
config['commands'][:create]['commands'].should include(:contexts)
|
47
|
-
|
48
|
-
config['commands'][:list].keys.should include('commands')
|
49
|
-
config['commands'][:list]['commands'].should include(:tasks)
|
50
|
-
config['commands'][:list]['commands'].should include(:contexts)
|
51
|
-
end
|
52
|
-
|
53
|
-
Given /^a config file that specifies defaults for some commands with subcommands$/ do
|
54
|
-
@config = {
|
55
|
-
'commands' => {
|
56
|
-
:list => {
|
57
|
-
'commands' => {
|
58
|
-
:tasks => {
|
59
|
-
:flag => 'foobar',
|
60
|
-
},
|
61
|
-
:contexts => {
|
62
|
-
:otherflag => 'crud',
|
63
|
-
},
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}
|
68
|
-
File.open(File.join(ENV['HOME'],'gli_test_todo.rc'),'w') do |file|
|
69
|
-
file.puts @config.to_yaml
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
Then /^I should see the defaults for '(.*)' from the config file in the help$/ do |command_path|
|
74
|
-
if command_path == 'list tasks'
|
75
|
-
step %{the output should match /--flag.*default: foobar/}
|
76
|
-
unescape(all_output).should_not =~ /#{unescape("--otherflag.*default: crud")}/m
|
77
|
-
elsif command_path == 'list contexts'
|
78
|
-
step %{the output should match /--otherflag.*default: crud/}
|
79
|
-
unescape(all_output).should_not =~ /#{unescape("--flag.*default: foobar")}/m
|
80
|
-
else
|
81
|
-
raise "Don't know how to test for command path #{command_path}"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
Given /^the todo app is coded to use verbatim formatting$/ do
|
87
|
-
ENV['TODO_WRAP_HELP_TEXT'] = 'verbatim'
|
88
|
-
end
|
89
|
-
|
90
|
-
Given(/^my terminal is (\d+) characters wide$/) do |terminal_width|
|
91
|
-
ENV['COLUMNS'] = terminal_width.to_s
|
92
|
-
end
|
93
|
-
|
94
|
-
Given(/^my app is configured for "(.*?)" synopses$/) do |synopsis|
|
95
|
-
ENV['SYNOPSES'] = synopsis
|
96
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'simplecov'
|
3
|
-
SimpleCov.start
|
4
|
-
rescue LoadError
|
5
|
-
# Don't care
|
6
|
-
end
|
7
|
-
require 'aruba/cucumber'
|
8
|
-
require 'fileutils'
|
9
|
-
|
10
|
-
# Adds GLI's bin dir to our path
|
11
|
-
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
12
|
-
GLI_LIB_PATH = File.expand_path(File.join(File.dirname(__FILE__),'..','..','lib'))
|
13
|
-
|
14
|
-
GLI_GEMSET = 'gli-testing'
|
15
|
-
TMP_PATH = 'tmp/aruba'
|
16
|
-
|
17
|
-
Before do
|
18
|
-
unset_bundler_env_vars
|
19
|
-
# Not sure how else to get this dynamically
|
20
|
-
@dirs = [TMP_PATH]
|
21
|
-
@aruba_timeout_seconds = 5
|
22
|
-
@original_path = ENV['PATH'].split(File::PATH_SEPARATOR)
|
23
|
-
@original_home = ENV['HOME']
|
24
|
-
new_home = "/tmp/fakehome"
|
25
|
-
FileUtils.rm_rf new_home
|
26
|
-
FileUtils.mkdir new_home
|
27
|
-
ENV['HOME'] = new_home
|
28
|
-
FileUtils.cp 'gli.rdoc','gli.rdoc.orig'
|
29
|
-
end
|
30
|
-
|
31
|
-
After do |scenario|
|
32
|
-
ENV['RUBYLIB'] = ''
|
33
|
-
todo_app_dir = File.join(TMP_PATH,'todo')
|
34
|
-
if File.exists? todo_app_dir
|
35
|
-
FileUtils.rm_rf(todo_app_dir)
|
36
|
-
end
|
37
|
-
ENV['PATH'] = @original_path.join(File::PATH_SEPARATOR)
|
38
|
-
ENV['HOME'] = @original_home
|
39
|
-
ENV['TODO_SORT_HELP'] = nil
|
40
|
-
ENV['TODO_WRAP_HELP_TEXT'] = nil
|
41
|
-
FileUtils.mv 'gli.rdoc.orig','gli.rdoc'
|
42
|
-
end
|
43
|
-
|
44
|
-
def add_to_path(dir)
|
45
|
-
ENV['PATH'] = "#{dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def add_to_lib_path(path)
|
49
|
-
ENV["RUBYLIB"] = (String(ENV["RUBYLIB"]).split(File::PATH_SEPARATOR) + [path]).join(File::PATH_SEPARATOR)
|
50
|
-
end
|
51
|
-
|
52
|
-
def remove_from_lib_path(path)
|
53
|
-
ENV["RUBYLIB"] = (String(ENV["RUBYLIB"]).split(File::PATH_SEPARATOR) - [path]).join(File::PATH_SEPARATOR)
|
54
|
-
end
|