File tree Expand file tree Collapse file tree 5 files changed +48
-0
lines changed Expand file tree Collapse file tree 5 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -644,6 +644,7 @@ def from_superclass(method, default = nil)
644
644
645
645
# A flag that makes the process exit with status 1 if any error happens.
646
646
def exit_on_failure?
647
+ Thor . deprecation_warning 'Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?`'
647
648
false
648
649
end
649
650
Original file line number Diff line number Diff line change 1
1
# module: random
2
2
3
3
class Amazing < Thor
4
+ def self . exit_on_failure?
5
+ false
6
+ end
7
+
4
8
desc "describe NAME" , "say that someone is amazing"
5
9
method_options :forcefully => :boolean
6
10
def describe ( name , opts )
Original file line number Diff line number Diff line change 1
1
class MyScript < Thor
2
2
check_unknown_options! :except => :with_optional
3
3
4
+ def self . exit_on_failure?
5
+ false
6
+ end
7
+
4
8
attr_accessor :some_attribute
5
9
attr_writer :another_attribute
6
10
attr_reader :another_attribute
@@ -180,6 +184,10 @@ module Scripts
180
184
class MyDefaults < Thor
181
185
check_unknown_options!
182
186
187
+ def self . exit_on_failure?
188
+ false
189
+ end
190
+
183
191
namespace :default
184
192
desc "cow" , "prints 'moo'"
185
193
def cow
@@ -200,6 +208,10 @@ module Scripts
200
208
end
201
209
202
210
class Arities < Thor
211
+ def self . exit_on_failure?
212
+ false
213
+ end
214
+
203
215
desc "zero_args" , "takes zero args"
204
216
def zero_args
205
217
end
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ def foo(name)
55
55
class Parent < Thor
56
56
desc "child1" , "child1 description"
57
57
subcommand "child1" , Child1
58
+
59
+ def self . exit_on_failure?
60
+ false
61
+ end
58
62
end
59
63
end
60
64
Original file line number Diff line number Diff line change @@ -173,6 +173,10 @@ def boring(*args)
173
173
def exec ( *args )
174
174
[ options , args ]
175
175
end
176
+
177
+ def self . exit_on_failure?
178
+ false
179
+ end
176
180
end
177
181
178
182
it "passes remaining args to command when it encounters a non-option" do
@@ -223,6 +227,10 @@ def exec(*args)
223
227
def checked ( *args )
224
228
[ options , args ]
225
229
end
230
+
231
+ def self . exit_on_failure?
232
+ false
233
+ end
226
234
end
227
235
228
236
it "still accept options and arguments" do
@@ -285,6 +293,10 @@ def exec(*args)
285
293
def boring ( *args )
286
294
[ options , args ]
287
295
end
296
+
297
+ def self . exit_on_failure?
298
+ false
299
+ end
288
300
end
289
301
290
302
it "does not check the required option in the given command" do
@@ -716,4 +728,19 @@ def unknown(*args)
716
728
expect ( MyScript . start ( %w( send ) ) ) . to eq ( true )
717
729
end
718
730
end
731
+
732
+ context "without an exit_on_failure? method" do
733
+ my_script = Class . new ( Thor ) do
734
+ desc "no arg" , "do nothing"
735
+ def no_arg
736
+ end
737
+ end
738
+
739
+ it "outputs a deprecation warning on error" do
740
+ expect do
741
+ my_script . start ( %w[ no_arg one ] )
742
+ end . to output ( /^Deprecation.*exit_on_failure/ ) . to_stderr
743
+ end
744
+ end
745
+
719
746
end
You can’t perform that action at this time.
0 commit comments