convoy 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.irbrc +3 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +705 -0
- data/Rakefile +1 -0
- data/convoy.gemspec +24 -0
- data/examples/.my_apprc +24 -0
- data/examples/basic +10 -0
- data/examples/basic_config_file +16 -0
- data/examples/basic_conflicts +17 -0
- data/examples/basic_depends_on +25 -0
- data/examples/basic_flags +15 -0
- data/examples/basic_options +14 -0
- data/examples/basic_options_multi +15 -0
- data/examples/basic_require_arguments +17 -0
- data/examples/basic_texts +21 -0
- data/examples/basic_validations +21 -0
- data/examples/basic_with_everything +30 -0
- data/examples/commands/example_command.rb +13 -0
- data/examples/suite_complex +65 -0
- data/examples/suite_simple +19 -0
- data/examples/suite_with_sub_commands +94 -0
- data/lib/convoy.rb +83 -0
- data/lib/convoy/action_command/base.rb +85 -0
- data/lib/convoy/action_command/escort_utility_command.rb +53 -0
- data/lib/convoy/app.rb +127 -0
- data/lib/convoy/arguments.rb +20 -0
- data/lib/convoy/auto_options.rb +71 -0
- data/lib/convoy/error/error.rb +33 -0
- data/lib/convoy/formatter/command.rb +87 -0
- data/lib/convoy/formatter/commands.rb +37 -0
- data/lib/convoy/formatter/cursor_position.rb +29 -0
- data/lib/convoy/formatter/default_help_formatter.rb +117 -0
- data/lib/convoy/formatter/global_command.rb +17 -0
- data/lib/convoy/formatter/option.rb +152 -0
- data/lib/convoy/formatter/options.rb +28 -0
- data/lib/convoy/formatter/shell_command_executor.rb +49 -0
- data/lib/convoy/formatter/stream_output_formatter.rb +88 -0
- data/lib/convoy/formatter/string_grid.rb +108 -0
- data/lib/convoy/formatter/string_splitter.rb +50 -0
- data/lib/convoy/formatter/terminal.rb +30 -0
- data/lib/convoy/global_pre_parser.rb +43 -0
- data/lib/convoy/logger.rb +75 -0
- data/lib/convoy/option_dependency_validator.rb +82 -0
- data/lib/convoy/option_parser.rb +155 -0
- data/lib/convoy/setup/configuration/generator.rb +75 -0
- data/lib/convoy/setup/configuration/instance.rb +34 -0
- data/lib/convoy/setup/configuration/loader.rb +43 -0
- data/lib/convoy/setup/configuration/locator/base.rb +19 -0
- data/lib/convoy/setup/configuration/locator/chaining.rb +29 -0
- data/lib/convoy/setup/configuration/locator/descending_to_home.rb +23 -0
- data/lib/convoy/setup/configuration/locator/executing_script_directory.rb +15 -0
- data/lib/convoy/setup/configuration/locator/specified_directory.rb +21 -0
- data/lib/convoy/setup/configuration/merge_tool.rb +38 -0
- data/lib/convoy/setup/configuration/reader.rb +36 -0
- data/lib/convoy/setup/configuration/writer.rb +46 -0
- data/lib/convoy/setup/dsl/action.rb +17 -0
- data/lib/convoy/setup/dsl/command.rb +67 -0
- data/lib/convoy/setup/dsl/config_file.rb +13 -0
- data/lib/convoy/setup/dsl/global.rb +29 -0
- data/lib/convoy/setup/dsl/options.rb +81 -0
- data/lib/convoy/setup_accessor.rb +206 -0
- data/lib/convoy/trollop.rb +861 -0
- data/lib/convoy/utils.rb +21 -0
- data/lib/convoy/validator.rb +45 -0
- data/spec/integration/basic_config_file_spec.rb +126 -0
- data/spec/integration/basic_conflicts_spec.rb +47 -0
- data/spec/integration/basic_depends_on_spec.rb +275 -0
- data/spec/integration/basic_options_spec.rb +41 -0
- data/spec/integration/basic_options_with_multi_spec.rb +30 -0
- data/spec/integration/basic_spec.rb +38 -0
- data/spec/integration/basic_validations_spec.rb +77 -0
- data/spec/integration/basic_with_arguments_spec.rb +35 -0
- data/spec/integration/basic_with_text_fields_spec.rb +21 -0
- data/spec/integration/suite_simple_spec.rb +45 -0
- data/spec/integration/suite_sub_command_spec.rb +51 -0
- data/spec/lib/convoy/action_command/base_spec.rb +200 -0
- data/spec/lib/convoy/formatter/command_spec.rb +238 -0
- data/spec/lib/convoy/formatter/global_command_spec.rb +50 -0
- data/spec/lib/convoy/formatter/option_spec.rb +300 -0
- data/spec/lib/convoy/formatter/shell_command_executor_spec.rb +59 -0
- data/spec/lib/convoy/formatter/stream_output_formatter_spec.rb +214 -0
- data/spec/lib/convoy/formatter/string_grid_spec.rb +59 -0
- data/spec/lib/convoy/formatter/string_splitter_spec.rb +50 -0
- data/spec/lib/convoy/formatter/terminal_spec.rb +19 -0
- data/spec/lib/convoy/setup/configuration/generator_spec.rb +101 -0
- data/spec/lib/convoy/setup/configuration/loader_spec.rb +79 -0
- data/spec/lib/convoy/setup/configuration/locator/chaining_spec.rb +81 -0
- data/spec/lib/convoy/setup/configuration/locator/descending_to_home_spec.rb +57 -0
- data/spec/lib/convoy/setup/configuration/locator/executing_script_directory_spec.rb +29 -0
- data/spec/lib/convoy/setup/configuration/locator/specified_directory_spec.rb +33 -0
- data/spec/lib/convoy/setup/configuration/merge_tool_spec.rb +41 -0
- data/spec/lib/convoy/setup/configuration/reader_spec.rb +41 -0
- data/spec/lib/convoy/setup/configuration/writer_spec.rb +75 -0
- data/spec/lib/convoy/setup_accessor_spec.rb +226 -0
- data/spec/lib/convoy/utils_spec.rb +30 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/integration_helpers.rb +2 -0
- data/spec/support/matchers/execute_action_for_command_matcher.rb +21 -0
- data/spec/support/matchers/execute_action_with_arguments_matcher.rb +25 -0
- data/spec/support/matchers/execute_action_with_options_matcher.rb +29 -0
- data/spec/support/matchers/exit_with_code_matcher.rb +29 -0
- data/spec/support/shared_contexts/integration_setup.rb +34 -0
- metadata +292 -0
@@ -0,0 +1,226 @@
|
|
1
|
+
describe Convoy::SetupAccessor do
|
2
|
+
let(:setup) { Convoy::SetupAccessor.new(app_configuration) }
|
3
|
+
|
4
|
+
let(:global_app_configuration) do
|
5
|
+
Convoy::Setup::Dsl::Global.new do |app|
|
6
|
+
app.options do |opts|
|
7
|
+
opts.opt :option1, "Option1", :short => '-o', :long => '--option1', :type => :string, :default => "option 1"
|
8
|
+
opts.opt :option2, "Option2", :short => :none, :long => '--option2', :type => :string, :multi => true
|
9
|
+
opts.opt :int_option, "Int option", :short => '-i', :long => '--int-option', :type => :int
|
10
|
+
opts.opt :flag1, "Flag 1", :short => '-f', :long => '--flag1', :type => :boolean, :default => true
|
11
|
+
opts.opt :flag2, "Flag 2", :short => :none, :long => '--flag2', :type => :boolean
|
12
|
+
|
13
|
+
opts.conflict :flag1, :flag2
|
14
|
+
opts.dependency :option1, :on => :flag1
|
15
|
+
opts.validate(:int_option, "must be greater than 10") { |option| option > 10 }
|
16
|
+
end
|
17
|
+
|
18
|
+
app.action do |options, arguments|
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:command_app_configuration) do
|
24
|
+
Convoy::Setup::Dsl::Global.new do |app|
|
25
|
+
app.options do |opts|
|
26
|
+
opts.opt :option1, "Option1", :short => '-o', :long => '--option1', :type => :string, :default => "option 1"
|
27
|
+
end
|
28
|
+
|
29
|
+
app.command :command1 do |command|
|
30
|
+
command.options do |opts|
|
31
|
+
opts.opt :option1, "Option1 for command1", :short => '-o', :long => '--option1', :type => :string, :default => "option 1 command 1"
|
32
|
+
opts.opt :flag_for_command1, "Flag for command 1", :short => :none, :long => '--flag-for-command1', :type => :boolean
|
33
|
+
|
34
|
+
opts.dependency :option1, :on => :flag_for_command1
|
35
|
+
end
|
36
|
+
|
37
|
+
command.action do |options, arguments|
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
app.command :command2, :aliases => :c2 do |command|
|
42
|
+
command.options do |opts|
|
43
|
+
opts.opt :optionb, "Optionb", :short => :none, :long => '--optionb', :type => :string, :multi => true
|
44
|
+
opts.opt :float_option, "Float option", :short => '-d', :long => '--float-option', :type => :float
|
45
|
+
|
46
|
+
opts.conflict :optionb, :float_option
|
47
|
+
opts.validate(:float_option, "must be less than 5") { |option| option < 5 }
|
48
|
+
end
|
49
|
+
|
50
|
+
command.action do |options, arguments|
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
app.action do |options, arguments|
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:sub_command_app_configuration) do
|
60
|
+
Convoy::Setup::Dsl::Global.new do |app|
|
61
|
+
app.options do |opts|
|
62
|
+
opts.opt :option1, "Option1", :short => '-o', :long => '--option1', :type => :string, :default => "option 1"
|
63
|
+
end
|
64
|
+
|
65
|
+
app.command :command2, :aliases => :c2 do |command|
|
66
|
+
command.options do |opts|
|
67
|
+
opts.opt :optionb, "Optionb", :short => :none, :long => '--optionb', :type => :string, :multi => true
|
68
|
+
opts.opt :float_option, "Float option", :short => '-d', :long => '--float-option', :type => :float
|
69
|
+
|
70
|
+
opts.conflict :optionb, :float_option
|
71
|
+
opts.validate(:float_option, "must be less than 5") { |option| option < 5 }
|
72
|
+
end
|
73
|
+
|
74
|
+
command.command :sub_command1 do |command|
|
75
|
+
command.options do |opts|
|
76
|
+
opts.opt :flag2, "Flag 2", :short => :none, :long => '--flag2', :type => :boolean
|
77
|
+
end
|
78
|
+
|
79
|
+
command.action do |options, arguments|
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
command.command :sub_command2 do |command|
|
84
|
+
command.options do |opts|
|
85
|
+
opts.opt :sub_option1, "Sub option1", :short => '-s', :long => '--sub-option1', :type => :string
|
86
|
+
opts.validate(:sub_option1, "must be 'x' or 'y'") { |option| ['x', 'y'].include? option }
|
87
|
+
end
|
88
|
+
|
89
|
+
command.action do |options, arguments|
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
command.action do |options, arguments|
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
app.action do |options, arguments|
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#options_for' do
|
103
|
+
let(:options) { setup.options_for(context) }
|
104
|
+
|
105
|
+
context "when app has no sub commands" do
|
106
|
+
let(:app_configuration) { global_app_configuration }
|
107
|
+
|
108
|
+
context "and context is global" do
|
109
|
+
let(:context) { [] }
|
110
|
+
it(":option1 should be present") { options[:option1].should_not be_nil }
|
111
|
+
end
|
112
|
+
|
113
|
+
context "and context is an unknown command" do
|
114
|
+
let(:context) { ['hello'] }
|
115
|
+
it("should not raise an exception") { expect { options }.to_not raise_error }
|
116
|
+
it("result should be a hash") { options.class.should == Hash }
|
117
|
+
it("result should be empty") { options.should be_empty }
|
118
|
+
end
|
119
|
+
|
120
|
+
context "and no context passed in at all" do
|
121
|
+
let(:options) { setup.options_for }
|
122
|
+
it(":option1 should be present") { options[:option1].should_not be_nil }
|
123
|
+
end
|
124
|
+
|
125
|
+
context "and context is nil" do
|
126
|
+
let(:context) { nil }
|
127
|
+
it(":option1 should be present") { options[:option1].should_not be_nil }
|
128
|
+
end
|
129
|
+
|
130
|
+
context "and context is not an array" do
|
131
|
+
let(:context) { 'hello' }
|
132
|
+
it("should not raise an exception") { expect { options }.to_not raise_error }
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when app has one level of sub commands" do
|
137
|
+
let(:app_configuration) { command_app_configuration }
|
138
|
+
|
139
|
+
context "and context is a known command" do
|
140
|
+
let(:context) { ['command1'] }
|
141
|
+
it("result should be a hash") { options.class.should == Hash }
|
142
|
+
it("result should not be empty") { options.should_not be_empty }
|
143
|
+
it(":option1 should be present") { options[:option1].should_not be_nil }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "when app has multiple levels of sub commands" do
|
148
|
+
let(:app_configuration) { sub_command_app_configuration }
|
149
|
+
|
150
|
+
context "and context is a known sub command" do
|
151
|
+
let(:context) { ['command2', 'sub_command2'] }
|
152
|
+
it("result should be a hash") { options.class.should == Hash }
|
153
|
+
it("result should not be empty") { options.should_not be_empty }
|
154
|
+
it(":sub_option1 should be present") { options[:sub_option1].should_not be_nil }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe '#conflicting_options_for' do
|
160
|
+
#TODO implement
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#validations_for' do
|
164
|
+
#TODO implement
|
165
|
+
end
|
166
|
+
|
167
|
+
describe '#dependencies_for' do
|
168
|
+
#TODO implement
|
169
|
+
end
|
170
|
+
|
171
|
+
describe '#command_names_for' do
|
172
|
+
#TODO implement
|
173
|
+
end
|
174
|
+
|
175
|
+
describe '#canonical_command_names_for' do
|
176
|
+
#TODO implement
|
177
|
+
end
|
178
|
+
|
179
|
+
describe '#action_for' do
|
180
|
+
#TODO implement
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#arguments_required_for' do
|
184
|
+
#TODO implement
|
185
|
+
end
|
186
|
+
|
187
|
+
describe '#has_config_file?' do
|
188
|
+
#TODO implement
|
189
|
+
end
|
190
|
+
|
191
|
+
describe '#config_file_autocreatable?' do
|
192
|
+
#TODO implement
|
193
|
+
end
|
194
|
+
|
195
|
+
describe '#config_file' do
|
196
|
+
#TODO implement
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#summary_for' do
|
200
|
+
#TODO implement
|
201
|
+
end
|
202
|
+
|
203
|
+
describe '#description_for' do
|
204
|
+
#TODO implement
|
205
|
+
end
|
206
|
+
|
207
|
+
describe '#command_description_for' do
|
208
|
+
#TODO implement
|
209
|
+
end
|
210
|
+
|
211
|
+
describe '#command_summary_for' do
|
212
|
+
#TODO implement
|
213
|
+
end
|
214
|
+
|
215
|
+
describe '#command_aliases_for' do
|
216
|
+
#TODO implement
|
217
|
+
end
|
218
|
+
|
219
|
+
describe '#add_global_option' do
|
220
|
+
#TODO implement
|
221
|
+
end
|
222
|
+
|
223
|
+
describe '#add_global_command' do
|
224
|
+
#TODO implement
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
describe Convoy::Utils do
|
2
|
+
describe '::symbolize_keys' do
|
3
|
+
subject { Convoy::Utils.symbolize_keys(hash) }
|
4
|
+
|
5
|
+
context "when single level hash" do
|
6
|
+
let(:hash) { {'a' => 1, :b => 2} }
|
7
|
+
it("the :a key should be a symbol") { subject[:a].should == 1 }
|
8
|
+
it("the :b key should be a symbol") { subject[:b].should == 2 }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when hash has nested hashes" do
|
12
|
+
let(:hash) { {'a' => 1, :b => {'c' => {'d' => 2}}} }
|
13
|
+
it("the :a key should be a symbol") { subject[:a].should == 1 }
|
14
|
+
it("the nested keys, :b, :c and :d should all be symbols") { subject[:b][:c][:d].should == 2 }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '::tokenize_option_string' do
|
19
|
+
subject { Convoy::Utils.tokenize_option_string(option_string) }
|
20
|
+
|
21
|
+
context "when option string has short option, long option and argument" do
|
22
|
+
let(:option_string) { "-a 1 --foo='bar blah' yadda" }
|
23
|
+
it("tokenized string should have 4 values") { subject.size.should == 4 }
|
24
|
+
it("the short option should be a separate token") { subject[0].should == '-a' }
|
25
|
+
it("the short option value should be a separate token") { subject[1].should == '1' }
|
26
|
+
it("the long option and value should be one token") { subject[2].should == '--foo=bar blah' }
|
27
|
+
it("the argument should be a separate token") { subject[3].should == 'yadda' }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'convoy'
|
2
|
+
require 'fakefs/safe'
|
3
|
+
require 'fakefs/spec_helpers'
|
4
|
+
|
5
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '**', "*.rb").to_s].each { |file| require file }
|
6
|
+
|
7
|
+
#helpers
|
8
|
+
#require 'helpers/exit_with_code_matcher'
|
9
|
+
#require 'helpers/execute_action_matcher'
|
10
|
+
#require 'helpers/give_option_to_action_with_value_matcher'
|
11
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
12
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
13
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
14
|
+
# loaded once.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
config.filter_run :focus
|
21
|
+
|
22
|
+
config.include IntegrationHelpers, :integration => true
|
23
|
+
|
24
|
+
# Run specs in random order to surface order dependencies. If you find an
|
25
|
+
# order dependency and want to debug it, you can fix the order by providing
|
26
|
+
# the seed, which is printed after each run.
|
27
|
+
# --seed 1234
|
28
|
+
config.order = 'random'
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec::Matchers.define :execute_action_for_command do |result, command_name|
|
2
|
+
match do |block|
|
3
|
+
begin
|
4
|
+
block.call
|
5
|
+
rescue SystemExit => e
|
6
|
+
end
|
7
|
+
result[:command_name] == command_name
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_for_should do |block|
|
11
|
+
"'#{command_name}' action should have been executed as a result of block, but instead '#{result[:command_name]}' was executed"
|
12
|
+
end
|
13
|
+
|
14
|
+
failure_message_for_should_not do |block|
|
15
|
+
"'#{command_name}' action should not have been executed as a result of block"
|
16
|
+
end
|
17
|
+
|
18
|
+
description do
|
19
|
+
"'#{command_name}' action should have been executed as a result of block"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec::Matchers.define :execute_action_with_arguments do |result, expected_arguments|
|
2
|
+
match do |block|
|
3
|
+
begin
|
4
|
+
block.call
|
5
|
+
rescue SystemExit => e
|
6
|
+
end
|
7
|
+
successful_match?(result, expected_arguments)
|
8
|
+
end
|
9
|
+
|
10
|
+
def successful_match?(result, expected_arguments)
|
11
|
+
result[:arguments] == expected_arguments
|
12
|
+
end
|
13
|
+
|
14
|
+
failure_message_for_should do |block|
|
15
|
+
"'#{expected_arguments}' should have been passed to action, but we got '#{result[:arguments]}'"
|
16
|
+
end
|
17
|
+
|
18
|
+
failure_message_for_should_not do |block|
|
19
|
+
"'#{expected_arguments}' should not have been passed to action"
|
20
|
+
end
|
21
|
+
|
22
|
+
description do
|
23
|
+
"'#{expected_arguments}' should have been passed to action"
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
RSpec::Matchers.define :execute_action_with_options do |result, expected_options|
|
2
|
+
match do |block|
|
3
|
+
begin
|
4
|
+
block.call
|
5
|
+
rescue SystemExit => e
|
6
|
+
end
|
7
|
+
successful_match?(result, expected_options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def successful_match?(result, expected_options)
|
11
|
+
options = result[:command_options]
|
12
|
+
expected_options.keys.each do |key|
|
13
|
+
return false unless options[key] == expected_options[key]
|
14
|
+
end
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
failure_message_for_should do |block|
|
19
|
+
"'#{expected_options}' should have been passed to action, but we got '#{result[:command_options]}'"
|
20
|
+
end
|
21
|
+
|
22
|
+
failure_message_for_should_not do |block|
|
23
|
+
"'#{expected_options}' should not have been passed to action"
|
24
|
+
end
|
25
|
+
|
26
|
+
description do
|
27
|
+
"'#{expected_options}' should have been passed to action"
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
RSpec::Matchers.define :exit_with_code do |*expected_code|
|
2
|
+
actual = nil
|
3
|
+
match do |block|
|
4
|
+
begin
|
5
|
+
block.call
|
6
|
+
rescue SystemExit => e
|
7
|
+
actual = e.status
|
8
|
+
end
|
9
|
+
has_expected_exit_code?(actual, *expected_code)
|
10
|
+
#actual && actual == expected_code
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_expected_exit_code?(actual, *expected_code)
|
14
|
+
expected_code.each do |code|
|
15
|
+
return true if actual && actual == code
|
16
|
+
end
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
failure_message_for_should do |block|
|
21
|
+
"expected block to call exit(#{expected_code}) but exit #{actual.nil? ? "not called" : "(#{actual}) was called"}"
|
22
|
+
end
|
23
|
+
failure_message_for_should_not do |block|
|
24
|
+
"expected block not to call exit(#{expected_code})"
|
25
|
+
end
|
26
|
+
description do
|
27
|
+
"expect block to call exit(#{expected_code})"
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
shared_context "integration test setup", :integration => true do
|
2
|
+
let(:result) { {} }
|
3
|
+
|
4
|
+
before do
|
5
|
+
empty_argv
|
6
|
+
#$stderr = StringIO.new
|
7
|
+
#$stdout = StringIO.new
|
8
|
+
#$stdin = StringIO.new
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
$stderr = STDERR
|
13
|
+
$stdout = STDOUT
|
14
|
+
$stdin = STDIN
|
15
|
+
end
|
16
|
+
|
17
|
+
module Convoy
|
18
|
+
class IntegrationTestCommand < ::Convoy::ActionCommand::Base
|
19
|
+
def execute(result)
|
20
|
+
result[:command_name] = command_name
|
21
|
+
result[:command_options] = command_options
|
22
|
+
result[:options] = options
|
23
|
+
result[:arguments] = arguments
|
24
|
+
result[:config] = config if config
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def empty_argv
|
30
|
+
while !ARGV.empty? do
|
31
|
+
ARGV.delete_at(0)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,292 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: convoy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Albert Rannetsperger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nesty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.1.0
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.1.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: fakefs
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.5'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.5.3
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.5'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.5.3
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rake
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '10.3'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 10.3.2
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.3'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 10.3.2
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: travis-lint
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.0'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.0.0
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.0.0
|
113
|
+
description: Writing even complex command-line apps should be quick, easy and fun.
|
114
|
+
Convoy takes the excellent Trollop option parser and adds a whole bunch of awesome
|
115
|
+
features to produce a library you will always want to turn to when a 'quick script'
|
116
|
+
is in order.
|
117
|
+
email: alb3rtuk@hotmail.com
|
118
|
+
executables: []
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- ".gitignore"
|
123
|
+
- ".irbrc"
|
124
|
+
- ".rspec"
|
125
|
+
- ".ruby-version"
|
126
|
+
- ".travis.yml"
|
127
|
+
- Gemfile
|
128
|
+
- LICENSE
|
129
|
+
- README.md
|
130
|
+
- Rakefile
|
131
|
+
- convoy.gemspec
|
132
|
+
- examples/.my_apprc
|
133
|
+
- examples/basic
|
134
|
+
- examples/basic_config_file
|
135
|
+
- examples/basic_conflicts
|
136
|
+
- examples/basic_depends_on
|
137
|
+
- examples/basic_flags
|
138
|
+
- examples/basic_options
|
139
|
+
- examples/basic_options_multi
|
140
|
+
- examples/basic_require_arguments
|
141
|
+
- examples/basic_texts
|
142
|
+
- examples/basic_validations
|
143
|
+
- examples/basic_with_everything
|
144
|
+
- examples/commands/example_command.rb
|
145
|
+
- examples/suite_complex
|
146
|
+
- examples/suite_simple
|
147
|
+
- examples/suite_with_sub_commands
|
148
|
+
- lib/convoy.rb
|
149
|
+
- lib/convoy/action_command/base.rb
|
150
|
+
- lib/convoy/action_command/escort_utility_command.rb
|
151
|
+
- lib/convoy/app.rb
|
152
|
+
- lib/convoy/arguments.rb
|
153
|
+
- lib/convoy/auto_options.rb
|
154
|
+
- lib/convoy/error/error.rb
|
155
|
+
- lib/convoy/formatter/command.rb
|
156
|
+
- lib/convoy/formatter/commands.rb
|
157
|
+
- lib/convoy/formatter/cursor_position.rb
|
158
|
+
- lib/convoy/formatter/default_help_formatter.rb
|
159
|
+
- lib/convoy/formatter/global_command.rb
|
160
|
+
- lib/convoy/formatter/option.rb
|
161
|
+
- lib/convoy/formatter/options.rb
|
162
|
+
- lib/convoy/formatter/shell_command_executor.rb
|
163
|
+
- lib/convoy/formatter/stream_output_formatter.rb
|
164
|
+
- lib/convoy/formatter/string_grid.rb
|
165
|
+
- lib/convoy/formatter/string_splitter.rb
|
166
|
+
- lib/convoy/formatter/terminal.rb
|
167
|
+
- lib/convoy/global_pre_parser.rb
|
168
|
+
- lib/convoy/logger.rb
|
169
|
+
- lib/convoy/option_dependency_validator.rb
|
170
|
+
- lib/convoy/option_parser.rb
|
171
|
+
- lib/convoy/setup/configuration/generator.rb
|
172
|
+
- lib/convoy/setup/configuration/instance.rb
|
173
|
+
- lib/convoy/setup/configuration/loader.rb
|
174
|
+
- lib/convoy/setup/configuration/locator/base.rb
|
175
|
+
- lib/convoy/setup/configuration/locator/chaining.rb
|
176
|
+
- lib/convoy/setup/configuration/locator/descending_to_home.rb
|
177
|
+
- lib/convoy/setup/configuration/locator/executing_script_directory.rb
|
178
|
+
- lib/convoy/setup/configuration/locator/specified_directory.rb
|
179
|
+
- lib/convoy/setup/configuration/merge_tool.rb
|
180
|
+
- lib/convoy/setup/configuration/reader.rb
|
181
|
+
- lib/convoy/setup/configuration/writer.rb
|
182
|
+
- lib/convoy/setup/dsl/action.rb
|
183
|
+
- lib/convoy/setup/dsl/command.rb
|
184
|
+
- lib/convoy/setup/dsl/config_file.rb
|
185
|
+
- lib/convoy/setup/dsl/global.rb
|
186
|
+
- lib/convoy/setup/dsl/options.rb
|
187
|
+
- lib/convoy/setup_accessor.rb
|
188
|
+
- lib/convoy/trollop.rb
|
189
|
+
- lib/convoy/utils.rb
|
190
|
+
- lib/convoy/validator.rb
|
191
|
+
- spec/integration/basic_config_file_spec.rb
|
192
|
+
- spec/integration/basic_conflicts_spec.rb
|
193
|
+
- spec/integration/basic_depends_on_spec.rb
|
194
|
+
- spec/integration/basic_options_spec.rb
|
195
|
+
- spec/integration/basic_options_with_multi_spec.rb
|
196
|
+
- spec/integration/basic_spec.rb
|
197
|
+
- spec/integration/basic_validations_spec.rb
|
198
|
+
- spec/integration/basic_with_arguments_spec.rb
|
199
|
+
- spec/integration/basic_with_text_fields_spec.rb
|
200
|
+
- spec/integration/suite_simple_spec.rb
|
201
|
+
- spec/integration/suite_sub_command_spec.rb
|
202
|
+
- spec/lib/convoy/action_command/base_spec.rb
|
203
|
+
- spec/lib/convoy/formatter/command_spec.rb
|
204
|
+
- spec/lib/convoy/formatter/global_command_spec.rb
|
205
|
+
- spec/lib/convoy/formatter/option_spec.rb
|
206
|
+
- spec/lib/convoy/formatter/shell_command_executor_spec.rb
|
207
|
+
- spec/lib/convoy/formatter/stream_output_formatter_spec.rb
|
208
|
+
- spec/lib/convoy/formatter/string_grid_spec.rb
|
209
|
+
- spec/lib/convoy/formatter/string_splitter_spec.rb
|
210
|
+
- spec/lib/convoy/formatter/terminal_spec.rb
|
211
|
+
- spec/lib/convoy/setup/configuration/generator_spec.rb
|
212
|
+
- spec/lib/convoy/setup/configuration/loader_spec.rb
|
213
|
+
- spec/lib/convoy/setup/configuration/locator/chaining_spec.rb
|
214
|
+
- spec/lib/convoy/setup/configuration/locator/descending_to_home_spec.rb
|
215
|
+
- spec/lib/convoy/setup/configuration/locator/executing_script_directory_spec.rb
|
216
|
+
- spec/lib/convoy/setup/configuration/locator/specified_directory_spec.rb
|
217
|
+
- spec/lib/convoy/setup/configuration/merge_tool_spec.rb
|
218
|
+
- spec/lib/convoy/setup/configuration/reader_spec.rb
|
219
|
+
- spec/lib/convoy/setup/configuration/writer_spec.rb
|
220
|
+
- spec/lib/convoy/setup_accessor_spec.rb
|
221
|
+
- spec/lib/convoy/utils_spec.rb
|
222
|
+
- spec/spec_helper.rb
|
223
|
+
- spec/support/integration_helpers.rb
|
224
|
+
- spec/support/matchers/execute_action_for_command_matcher.rb
|
225
|
+
- spec/support/matchers/execute_action_with_arguments_matcher.rb
|
226
|
+
- spec/support/matchers/execute_action_with_options_matcher.rb
|
227
|
+
- spec/support/matchers/exit_with_code_matcher.rb
|
228
|
+
- spec/support/shared_contexts/integration_setup.rb
|
229
|
+
homepage: http://github.com/alb3rtuk/convoy
|
230
|
+
licenses:
|
231
|
+
- MIT
|
232
|
+
metadata: {}
|
233
|
+
post_install_message:
|
234
|
+
rdoc_options: []
|
235
|
+
require_paths:
|
236
|
+
- lib
|
237
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - ">="
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: '0'
|
242
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - ">="
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '0'
|
247
|
+
requirements: []
|
248
|
+
rubyforge_project:
|
249
|
+
rubygems_version: 2.4.1
|
250
|
+
signing_key:
|
251
|
+
specification_version: 4
|
252
|
+
summary: A library that makes building command line apps in ruby so easy, you'll feel
|
253
|
+
like an expert is guiding you through it
|
254
|
+
test_files:
|
255
|
+
- spec/integration/basic_config_file_spec.rb
|
256
|
+
- spec/integration/basic_conflicts_spec.rb
|
257
|
+
- spec/integration/basic_depends_on_spec.rb
|
258
|
+
- spec/integration/basic_options_spec.rb
|
259
|
+
- spec/integration/basic_options_with_multi_spec.rb
|
260
|
+
- spec/integration/basic_spec.rb
|
261
|
+
- spec/integration/basic_validations_spec.rb
|
262
|
+
- spec/integration/basic_with_arguments_spec.rb
|
263
|
+
- spec/integration/basic_with_text_fields_spec.rb
|
264
|
+
- spec/integration/suite_simple_spec.rb
|
265
|
+
- spec/integration/suite_sub_command_spec.rb
|
266
|
+
- spec/lib/convoy/action_command/base_spec.rb
|
267
|
+
- spec/lib/convoy/formatter/command_spec.rb
|
268
|
+
- spec/lib/convoy/formatter/global_command_spec.rb
|
269
|
+
- spec/lib/convoy/formatter/option_spec.rb
|
270
|
+
- spec/lib/convoy/formatter/shell_command_executor_spec.rb
|
271
|
+
- spec/lib/convoy/formatter/stream_output_formatter_spec.rb
|
272
|
+
- spec/lib/convoy/formatter/string_grid_spec.rb
|
273
|
+
- spec/lib/convoy/formatter/string_splitter_spec.rb
|
274
|
+
- spec/lib/convoy/formatter/terminal_spec.rb
|
275
|
+
- spec/lib/convoy/setup/configuration/generator_spec.rb
|
276
|
+
- spec/lib/convoy/setup/configuration/loader_spec.rb
|
277
|
+
- spec/lib/convoy/setup/configuration/locator/chaining_spec.rb
|
278
|
+
- spec/lib/convoy/setup/configuration/locator/descending_to_home_spec.rb
|
279
|
+
- spec/lib/convoy/setup/configuration/locator/executing_script_directory_spec.rb
|
280
|
+
- spec/lib/convoy/setup/configuration/locator/specified_directory_spec.rb
|
281
|
+
- spec/lib/convoy/setup/configuration/merge_tool_spec.rb
|
282
|
+
- spec/lib/convoy/setup/configuration/reader_spec.rb
|
283
|
+
- spec/lib/convoy/setup/configuration/writer_spec.rb
|
284
|
+
- spec/lib/convoy/setup_accessor_spec.rb
|
285
|
+
- spec/lib/convoy/utils_spec.rb
|
286
|
+
- spec/spec_helper.rb
|
287
|
+
- spec/support/integration_helpers.rb
|
288
|
+
- spec/support/matchers/execute_action_for_command_matcher.rb
|
289
|
+
- spec/support/matchers/execute_action_with_arguments_matcher.rb
|
290
|
+
- spec/support/matchers/execute_action_with_options_matcher.rb
|
291
|
+
- spec/support/matchers/exit_with_code_matcher.rb
|
292
|
+
- spec/support/shared_contexts/integration_setup.rb
|