gli 2.18.2 → 2.20.1

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +28 -0
  3. data/.gitignore +1 -3
  4. data/.tool-versions +1 -1
  5. data/Gemfile +0 -6
  6. data/README.rdoc +33 -23
  7. data/Rakefile +21 -37
  8. data/bin/ci +29 -0
  9. data/bin/gli +25 -64
  10. data/bin/rake +29 -0
  11. data/bin/setup +5 -0
  12. data/exe/gli +68 -0
  13. data/gli.gemspec +19 -22
  14. data/gli.rdoc +2 -2
  15. data/lib/gli/command_support.rb +2 -6
  16. data/lib/gli/commands/help_modules/arg_name_formatter.rb +2 -2
  17. data/lib/gli/commands/help_modules/command_help_format.rb +1 -1
  18. data/lib/gli/commands/help_modules/global_help_format.rb +1 -1
  19. data/lib/gli/commands/scaffold.rb +9 -93
  20. data/lib/gli/dsl.rb +1 -1
  21. data/lib/gli/options.rb +2 -2
  22. data/lib/gli/version.rb +1 -1
  23. data/object-model.dot +29 -0
  24. data/object-model.png +0 -0
  25. data/test/apps/todo/Gemfile +1 -1
  26. data/test/apps/todo/bin/todo +1 -1
  27. data/test/integration/gli_cli_test.rb +69 -0
  28. data/test/integration/gli_powered_app_test.rb +52 -0
  29. data/test/integration/scaffold_test.rb +30 -0
  30. data/test/integration/test_helper.rb +52 -0
  31. data/test/{tc_command_finder.rb → unit/command_finder_test.rb} +6 -6
  32. data/test/{tc_command.rb → unit/command_test.rb} +4 -4
  33. data/test/unit/compound_command_test.rb +17 -0
  34. data/test/{tc_doc.rb → unit/doc_test.rb} +38 -51
  35. data/test/{tc_flag.rb → unit/flag_test.rb} +19 -25
  36. data/test/{tc_gli.rb → unit/gli_test.rb} +28 -47
  37. data/test/{tc_help.rb → unit/help_test.rb} +48 -107
  38. data/test/{init_simplecov.rb → unit/init_simplecov.rb} +0 -0
  39. data/test/{tc_options.rb → unit/options_test.rb} +4 -4
  40. data/test/unit/subcommand_parsing_test.rb +263 -0
  41. data/test/unit/subcommands_test.rb +245 -0
  42. data/test/{fake_std_out.rb → unit/support/fake_std_out.rb} +0 -0
  43. data/test/{config.yaml → unit/support/gli_test_config.yml} +0 -0
  44. data/test/unit/switch_test.rb +49 -0
  45. data/test/{tc_terminal.rb → unit/terminal_test.rb} +4 -3
  46. data/test/unit/test_helper.rb +13 -0
  47. data/test/unit/verbatim_wrapper_test.rb +24 -0
  48. metadata +74 -139
  49. data/.ruby-gemset +0 -1
  50. data/.ruby-version +0 -1
  51. data/.travis.yml +0 -11
  52. data/ObjectModel.graffle +0 -1191
  53. data/bin/report_on_rake_results +0 -10
  54. data/bin/test_all_rubies.sh +0 -6
  55. data/features/gli_executable.feature +0 -90
  56. data/features/gli_init.feature +0 -235
  57. data/features/step_definitions/gli_executable_steps.rb +0 -18
  58. data/features/step_definitions/gli_init_steps.rb +0 -11
  59. data/features/step_definitions/todo_steps.rb +0 -100
  60. data/features/support/env.rb +0 -54
  61. data/features/todo.feature +0 -579
  62. data/features/todo_legacy.feature +0 -130
  63. data/test/option_test_helper.rb +0 -13
  64. data/test/tc_compound_command.rb +0 -22
  65. data/test/tc_subcommand_parsing.rb +0 -280
  66. data/test/tc_subcommands.rb +0 -259
  67. data/test/tc_switch.rb +0 -55
  68. data/test/tc_verbatim_wrapper.rb +0 -36
  69. 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][, [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,235 +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
- |todo/.git |
39
- And the following files should exist:
40
- |todo/bin/todo |
41
- |todo/README.rdoc |
42
- |todo/todo.rdoc |
43
- |todo/todo.gemspec |
44
- |todo/test/default_test.rb |
45
- |todo/test/test_helper.rb |
46
- |todo/Rakefile |
47
- |todo/Gemfile |
48
- |todo/lib/todo/version.rb |
49
- |todo/lib/todo.rb |
50
- |todo/.rvmrc |
51
- And the file "todo/README.rdoc" should contain ":include:todo.rdoc"
52
- And the file "todo/todo.rdoc" should contain "todo _doc"
53
- When I cd to "todo"
54
- And I make sure todo's lib dir is in my lib path
55
- And I run `bin/todo`
56
- Then the output should contain:
57
- """
58
- NAME
59
- todo - Describe your application here
60
-
61
- SYNOPSIS
62
- todo [global options] command [command options] [arguments...]
63
-
64
- VERSION
65
- 0.0.1
66
-
67
- GLOBAL OPTIONS
68
- -f, --flagname=The name of the argument - Describe some flag here (default:
69
- the default)
70
- --help - Show this message
71
- -s, --[no-]switch - Describe some switch here
72
- --version - Display the program version
73
-
74
- COMMANDS
75
- add - Describe add here
76
- complete - Describe complete here
77
- help - Shows a list of commands or help for one command
78
- list - Describe list here
79
-
80
- """
81
- And I run `bin/todo --help`
82
- Then the output should contain:
83
- """
84
- NAME
85
- todo - Describe your application here
86
-
87
- SYNOPSIS
88
- todo [global options] command [command options] [arguments...]
89
-
90
- VERSION
91
- 0.0.1
92
-
93
- GLOBAL OPTIONS
94
- -f, --flagname=The name of the argument - Describe some flag here (default:
95
- the default)
96
- --help - Show this message
97
- -s, --[no-]switch - Describe some switch here
98
- --version - Display the program version
99
-
100
- COMMANDS
101
- add - Describe add here
102
- complete - Describe complete here
103
- help - Shows a list of commands or help for one command
104
- list - Describe list here
105
-
106
- """
107
- When I run `bin/todo help add`
108
- Then the output should contain:
109
- """
110
- NAME
111
- add - Describe add here
112
- """
113
- And the output should contain:
114
- """
115
- SYNOPSIS
116
- todo [global options] add [command options] Describe arguments to add here
117
- """
118
- And the output should contain:
119
- """
120
- COMMAND OPTIONS
121
- -f arg - Describe a flag to add (default: default)
122
- -s - Describe a switch to add
123
- """
124
- When I run `rake test`
125
- Then the output should contain:
126
- """
127
- .
128
- """
129
- And the output should contain:
130
- """
131
-
132
- 1 tests, 1 assertions, 0 failures, 0 errors
133
- """
134
- Given todo's libs are no longer in my load path
135
- When I run `rake features`
136
- Then the output should contain:
137
- """
138
- 1 scenario (1 passed)
139
- """
140
- And the output should contain:
141
- """
142
- 2 steps (2 passed)
143
- """
144
-
145
- Scenario Outline: Scaffold generates and respects flags to create ext dir and avoid test dir
146
- When I run `<command>`
147
- Then the exit status should be 0
148
- And the output should contain exactly:
149
- """
150
- Creating dir ./todo/lib...
151
- Creating dir ./todo/bin...
152
- Creating dir ./todo/ext...
153
- Created ./todo/bin/todo
154
- Created ./todo/README.rdoc
155
- Created ./todo/todo.rdoc
156
- Created ./todo/todo.gemspec
157
- Created ./todo/Rakefile
158
- Created ./todo/Gemfile
159
- Created ./todo/lib/todo/version.rb
160
- Created ./todo/lib/todo.rb
161
-
162
- """
163
- And the following directories should exist:
164
- |todo |
165
- |todo/bin |
166
- |todo/ext |
167
- |todo/lib |
168
- And the following directories should not exist:
169
- |todo/test|
170
- And the following files should exist:
171
- |todo/bin/todo |
172
- |todo/README.rdoc |
173
- |todo/todo.rdoc |
174
- |todo/todo.gemspec |
175
- |todo/Rakefile |
176
- |todo/Gemfile |
177
- |todo/lib/todo/version.rb |
178
- |todo/lib/todo.rb |
179
-
180
- Examples:
181
- | command |
182
- | gli init -e --notest todo add complete list |
183
- | gli init todo add complete list -e --notest |
184
-
185
- Scenario: Running commands the normal way
186
- Given I successfully run `gli init todo add complete compute list`
187
- And I cd to "todo"
188
- And I make sure todo's lib dir is in my lib path
189
- When I successfully run `bin/todo add`
190
- Then the output should contain "add command ran"
191
- When I successfully run `bin/todo complete`
192
- Then the output should contain "complete command ran"
193
- When I run `bin/todo foobar`
194
- Then the stderr should contain "error: Unknown command 'foobar'"
195
- And the exit status should not be 0
196
-
197
- Scenario: Running commands using short form
198
- Given I successfully run `gli init todo add complete compute list`
199
- And I cd to "todo"
200
- And I make sure todo's lib dir is in my lib path
201
- When I successfully run `bin/todo a`
202
- Then the output should contain "add command ran"
203
- When I successfully run `bin/todo l`
204
- Then the output should contain "list command ran"
205
- When I successfully run `bin/todo compl`
206
- Then the output should contain "complete command ran"
207
-
208
- Scenario: Ambiguous commands give helpful output
209
- Given I successfully run `gli init todo add complete compute list`
210
- And I cd to "todo"
211
- And I make sure todo's lib dir is in my lib path
212
- When I run `bin/todo comp`
213
- Then the stderr should contain "Ambiguous command 'comp'. It matches complete,compute"
214
- And the exit status should not be 0
215
-
216
- Scenario: Running generated command without bundler gives a helpful error message
217
- Given I successfully run `gli init todo add complete compute list`
218
- And I cd to "todo"
219
- When I run `bin/todo comp`
220
- Then the exit status should not be 0
221
- Then the stderr should contain "In development, you need to use `bundle exec bin/todo` to run your app"
222
- And the stderr should contain "At install-time, RubyGems will make sure lib, etc. are in the load path"
223
- And the stderr should contain "Feel free to remove this message from bin/todo now"
224
-
225
- Scenario: Running commands with a dash in the name
226
- Given I successfully run `gli init todo-app add complete compute list`
227
- And I cd to "todo-app"
228
- And I make sure todo's lib dir is in my lib path
229
- When I successfully run `bin/todo-app add`
230
- Then the output should contain "add command ran"
231
- When I successfully run `bin/todo-app complete`
232
- Then the output should contain "complete command ran"
233
- When I run `bin/todo-app foobar`
234
- Then the stderr should contain "error: Unknown command 'foobar'"
235
- 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