gli 2.19.2 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +28 -0
  3. data/.gitignore +1 -3
  4. data/Gemfile +0 -6
  5. data/README.rdoc +2 -12
  6. data/Rakefile +15 -37
  7. data/bin/ci +29 -0
  8. data/bin/gli +25 -64
  9. data/bin/rake +29 -0
  10. data/bin/setup +5 -0
  11. data/exe/gli +68 -0
  12. data/gli.gemspec +19 -21
  13. data/gli.rdoc +2 -2
  14. data/lib/gli/commands/help_modules/command_help_format.rb +1 -1
  15. data/lib/gli/commands/help_modules/global_help_format.rb +1 -1
  16. data/lib/gli/commands/scaffold.rb +9 -93
  17. data/lib/gli/options.rb +2 -2
  18. data/lib/gli/version.rb +1 -1
  19. data/object-model.dot +29 -0
  20. data/object-model.png +0 -0
  21. data/test/apps/todo/Gemfile +1 -1
  22. data/test/apps/todo/bin/todo +1 -1
  23. data/test/integration/gli_cli_test.rb +69 -0
  24. data/test/integration/gli_powered_app_test.rb +52 -0
  25. data/test/integration/scaffold_test.rb +30 -0
  26. data/test/integration/test_helper.rb +52 -0
  27. data/test/{tc_command_finder.rb → unit/command_finder_test.rb} +6 -6
  28. data/test/{tc_command.rb → unit/command_test.rb} +4 -4
  29. data/test/unit/compound_command_test.rb +17 -0
  30. data/test/{tc_doc.rb → unit/doc_test.rb} +38 -51
  31. data/test/{tc_flag.rb → unit/flag_test.rb} +19 -25
  32. data/test/{tc_gli.rb → unit/gli_test.rb} +28 -47
  33. data/test/{tc_help.rb → unit/help_test.rb} +48 -107
  34. data/test/{init_simplecov.rb → unit/init_simplecov.rb} +0 -0
  35. data/test/{tc_options.rb → unit/options_test.rb} +4 -4
  36. data/test/unit/subcommand_parsing_test.rb +263 -0
  37. data/test/unit/subcommands_test.rb +245 -0
  38. data/test/{fake_std_out.rb → unit/support/fake_std_out.rb} +0 -0
  39. data/test/{config.yaml → unit/support/gli_test_config.yml} +0 -0
  40. data/test/unit/switch_test.rb +49 -0
  41. data/test/{tc_terminal.rb → unit/terminal_test.rb} +4 -3
  42. data/test/unit/test_helper.rb +13 -0
  43. data/test/unit/verbatim_wrapper_test.rb +24 -0
  44. metadata +57 -124
  45. data/.ruby-gemset +0 -1
  46. data/.ruby-version +0 -1
  47. data/.travis.yml +0 -11
  48. data/ObjectModel.graffle +0 -1191
  49. data/bin/report_on_rake_results +0 -10
  50. data/bin/test_all_rubies.sh +0 -6
  51. data/features/gli_executable.feature +0 -90
  52. data/features/gli_init.feature +0 -236
  53. data/features/step_definitions/gli_executable_steps.rb +0 -18
  54. data/features/step_definitions/gli_init_steps.rb +0 -11
  55. data/features/step_definitions/todo_steps.rb +0 -100
  56. data/features/support/env.rb +0 -54
  57. data/features/support/hooks.rb +0 -5
  58. data/features/todo.feature +0 -579
  59. data/features/todo_legacy.feature +0 -130
  60. data/test/option_test_helper.rb +0 -13
  61. data/test/tc_compound_command.rb +0 -22
  62. data/test/tc_subcommand_parsing.rb +0 -280
  63. data/test/tc_subcommands.rb +0 -259
  64. data/test/tc_switch.rb +0 -55
  65. data/test/tc_verbatim_wrapper.rb +0 -36
  66. data/test/test_helper.rb +0 -21
@@ -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?
@@ -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_name]...
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
@@ -1,236 +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
- @slow-command
12
- Scenario: Scaffold generates and things look good
13
- When I run `gli init --rvmrc todo add complete list`
14
- Then the exit status should be 0
15
- And the output should contain exactly:
16
- """
17
- Creating dir ./todo/lib...
18
- Creating dir ./todo/bin...
19
- Creating dir ./todo/test...
20
- Created ./todo/bin/todo
21
- Created ./todo/README.rdoc
22
- Created ./todo/todo.rdoc
23
- Created ./todo/todo.gemspec
24
- Created ./todo/test/default_test.rb
25
- Created ./todo/test/test_helper.rb
26
- Created ./todo/Rakefile
27
- Created ./todo/Gemfile
28
- Created ./todo/features
29
- Created ./todo/lib/todo/version.rb
30
- Created ./todo/lib/todo.rb
31
- Created ./todo/.rvmrc
32
-
33
- """
34
- And the following directories should exist:
35
- |todo |
36
- |todo/bin |
37
- |todo/test |
38
- |todo/lib |
39
- |todo/.git |
40
- And the following files should exist:
41
- |todo/bin/todo |
42
- |todo/README.rdoc |
43
- |todo/todo.rdoc |
44
- |todo/todo.gemspec |
45
- |todo/test/default_test.rb |
46
- |todo/test/test_helper.rb |
47
- |todo/Rakefile |
48
- |todo/Gemfile |
49
- |todo/lib/todo/version.rb |
50
- |todo/lib/todo.rb |
51
- |todo/.rvmrc |
52
- And the file "todo/README.rdoc" should contain ":include:todo.rdoc"
53
- And the file "todo/todo.rdoc" should contain "todo _doc"
54
- When I cd to "todo"
55
- And I make sure todo's lib dir is in my lib path
56
- And I run `bin/todo`
57
- Then the output should contain:
58
- """
59
- NAME
60
- todo - Describe your application here
61
-
62
- SYNOPSIS
63
- todo [global options] command [command options] [arguments...]
64
-
65
- VERSION
66
- 0.0.1
67
-
68
- GLOBAL OPTIONS
69
- -f, --flagname=The name of the argument - Describe some flag here (default:
70
- the default)
71
- --help - Show this message
72
- -s, --[no-]switch - Describe some switch here
73
- --version - Display the program version
74
-
75
- COMMANDS
76
- add - Describe add here
77
- complete - Describe complete here
78
- help - Shows a list of commands or help for one command
79
- list - Describe list here
80
-
81
- """
82
- And I run `bin/todo --help`
83
- Then the output should contain:
84
- """
85
- NAME
86
- todo - Describe your application here
87
-
88
- SYNOPSIS
89
- todo [global options] command [command options] [arguments...]
90
-
91
- VERSION
92
- 0.0.1
93
-
94
- GLOBAL OPTIONS
95
- -f, --flagname=The name of the argument - Describe some flag here (default:
96
- the default)
97
- --help - Show this message
98
- -s, --[no-]switch - Describe some switch here
99
- --version - Display the program version
100
-
101
- COMMANDS
102
- add - Describe add here
103
- complete - Describe complete here
104
- help - Shows a list of commands or help for one command
105
- list - Describe list here
106
-
107
- """
108
- When I run `bin/todo help add`
109
- Then the output should contain:
110
- """
111
- NAME
112
- add - Describe add here
113
- """
114
- And the output should contain:
115
- """
116
- SYNOPSIS
117
- todo [global options] add [command options] Describe arguments to add here
118
- """
119
- And the output should contain:
120
- """
121
- COMMAND OPTIONS
122
- -f arg - Describe a flag to add (default: default)
123
- -s - Describe a switch to add
124
- """
125
- When I run `rake test`
126
- Then the output should contain:
127
- """
128
- .
129
- """
130
- And the output should contain:
131
- """
132
-
133
- 1 tests, 1 assertions, 0 failures, 0 errors
134
- """
135
- Given todo's libs are no longer in my load path
136
- When I run `rake features`
137
- Then the output should contain:
138
- """
139
- 1 scenario (1 passed)
140
- """
141
- And the output should contain:
142
- """
143
- 2 steps (2 passed)
144
- """
145
-
146
- Scenario Outline: Scaffold generates and respects flags to create ext dir and avoid test dir
147
- When I run `<command>`
148
- Then the exit status should be 0
149
- And the output should contain exactly:
150
- """
151
- Creating dir ./todo/lib...
152
- Creating dir ./todo/bin...
153
- Creating dir ./todo/ext...
154
- Created ./todo/bin/todo
155
- Created ./todo/README.rdoc
156
- Created ./todo/todo.rdoc
157
- Created ./todo/todo.gemspec
158
- Created ./todo/Rakefile
159
- Created ./todo/Gemfile
160
- Created ./todo/lib/todo/version.rb
161
- Created ./todo/lib/todo.rb
162
-
163
- """
164
- And the following directories should exist:
165
- |todo |
166
- |todo/bin |
167
- |todo/ext |
168
- |todo/lib |
169
- And the following directories should not exist:
170
- |todo/test|
171
- And the following files should exist:
172
- |todo/bin/todo |
173
- |todo/README.rdoc |
174
- |todo/todo.rdoc |
175
- |todo/todo.gemspec |
176
- |todo/Rakefile |
177
- |todo/Gemfile |
178
- |todo/lib/todo/version.rb |
179
- |todo/lib/todo.rb |
180
-
181
- Examples:
182
- | command |
183
- | gli init -e --notest todo add complete list |
184
- | gli init todo add complete list -e --notest |
185
-
186
- Scenario: Running commands the normal way
187
- Given I successfully run `gli init todo add complete compute list`
188
- And I cd to "todo"
189
- And I make sure todo's lib dir is in my lib path
190
- When I successfully run `bin/todo add`
191
- Then the output should contain "add command ran"
192
- When I successfully run `bin/todo complete`
193
- Then the output should contain "complete command ran"
194
- When I run `bin/todo foobar`
195
- Then the stderr should contain "error: Unknown command 'foobar'"
196
- And the exit status should not be 0
197
-
198
- Scenario: Running commands using short form
199
- Given I successfully run `gli init todo add complete compute list`
200
- And I cd to "todo"
201
- And I make sure todo's lib dir is in my lib path
202
- When I successfully run `bin/todo a`
203
- Then the output should contain "add command ran"
204
- When I successfully run `bin/todo l`
205
- Then the output should contain "list command ran"
206
- When I successfully run `bin/todo compl`
207
- Then the output should contain "complete command ran"
208
-
209
- Scenario: Ambiguous commands give helpful output
210
- Given I successfully run `gli init todo add complete compute list`
211
- And I cd to "todo"
212
- And I make sure todo's lib dir is in my lib path
213
- When I run `bin/todo comp`
214
- Then the stderr should contain "Ambiguous command 'comp'. It matches complete,compute"
215
- And the exit status should not be 0
216
-
217
- Scenario: Running generated command without bundler gives a helpful error message
218
- Given I successfully run `gli init todo add complete compute list`
219
- And I cd to "todo"
220
- When I run `bin/todo comp`
221
- Then the exit status should not be 0
222
- Then the stderr should contain "In development, you need to use `bundle exec bin/todo` to run your app"
223
- And the stderr should contain "At install-time, RubyGems will make sure lib, etc. are in the load path"
224
- And the stderr should contain "Feel free to remove this message from bin/todo now"
225
-
226
- Scenario: Running commands with a dash in the name
227
- Given I successfully run `gli init todo-app add complete compute list`
228
- And I cd to "todo-app"
229
- And I make sure todo's lib dir is in my lib path
230
- When I successfully run `bin/todo-app add`
231
- Then the output should contain "add command ran"
232
- When I successfully run `bin/todo-app complete`
233
- Then the output should contain "complete command ran"
234
- When I run `bin/todo-app foobar`
235
- Then the stderr should contain "error: Unknown command 'foobar'"
236
- 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.exist?(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,100 +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 /^the todo app is coded to hide commands without description$/ do
22
- ENV['HIDE_COMMANDS_WITHOUT_DESC'] = 'true'
23
- end
24
-
25
- Given /^a clean home directory$/ do
26
- FileUtils.rm_rf File.join(ENV['HOME'],'gli_test_todo.rc')
27
- end
28
-
29
- Then /^the config file should contain a section for each command and subcommand$/ do
30
- config = File.open(File.join(ENV['HOME'],'gli_test_todo.rc')) do |file|
31
- YAML::load(file)
32
- end
33
- expect(config.keys).to include(:flag)
34
- expect(config[:flag]).to eq('foo')
35
- config[:flag].tap do |flag|
36
- if flag.respond_to?(:encoding)
37
- expect(flag.encoding.name).to eq('UTF-8')
38
- end
39
- end
40
- expect(config.keys).to include(:switch)
41
- expect(config[:switch]).to eq(true)
42
- expect(config.keys).to include(:otherswitch)
43
- expect(config[:otherswitch]).to eq(false)
44
- expect(config.keys).to include('commands')
45
- %w(chained chained2 create first list ls second).map(&:to_sym).each do |command_name|
46
- expect(config['commands'].keys).to include(command_name)
47
- end
48
- expect(config['commands'][:create].keys).to include('commands')
49
- expect(config['commands'][:create]['commands']).to include(:tasks)
50
- expect(config['commands'][:create]['commands']).to include(:contexts)
51
-
52
- expect(config['commands'][:list].keys).to include('commands')
53
- expect(config['commands'][:list]['commands']).to include(:tasks)
54
- expect(config['commands'][:list]['commands']).to include(:contexts)
55
- end
56
-
57
- Given /^a config file that specifies defaults for some commands with subcommands$/ do
58
- @config = {
59
- 'commands' => {
60
- :list => {
61
- 'commands' => {
62
- :tasks => {
63
- :flag => 'foobar',
64
- },
65
- :contexts => {
66
- :otherflag => 'crud',
67
- },
68
- }
69
- }
70
- }
71
- }
72
- File.open(File.join(ENV['HOME'],'gli_test_todo.rc'),'w') do |file|
73
- file.puts @config.to_yaml
74
- end
75
- end
76
-
77
- Then /^I should see the defaults for '(.*)' from the config file in the help$/ do |command_path|
78
- if command_path == 'list tasks'
79
- step %{the output should match /--flag.*default: foobar/}
80
- expect(unescape(all_output)).not_to match(/#{unescape("--otherflag.*default: crud")}/m)
81
- elsif command_path == 'list contexts'
82
- step %{the output should match /--otherflag.*default: crud/}
83
- expect(unescape(all_output)).not_to match(/#{unescape("--flag.*default: foobar")}/m)
84
- else
85
- raise "Don't know how to test for command path #{command_path}"
86
- end
87
- end
88
-
89
-
90
- Given /^the todo app is coded to use verbatim formatting$/ do
91
- ENV['TODO_WRAP_HELP_TEXT'] = 'verbatim'
92
- end
93
-
94
- Given(/^my terminal is (\d+) characters wide$/) do |terminal_width|
95
- ENV['COLUMNS'] = terminal_width.to_s
96
- end
97
-
98
- Given(/^my app is configured for "(.*?)" synopses$/) do |synopsis|
99
- ENV['SYNOPSES'] = synopsis
100
- end