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)
644644
645645 # A flag that makes the process exit with status 1 if any error happens.
646646 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?`'
647648 false
648649 end
649650
Original file line number Diff line number Diff line change 11# module: random
22
33class Amazing < Thor
4+ def self . exit_on_failure?
5+ false
6+ end
7+
48 desc "describe NAME" , "say that someone is amazing"
59 method_options :forcefully => :boolean
610 def describe ( name , opts )
Original file line number Diff line number Diff line change 11class MyScript < Thor
22 check_unknown_options! :except => :with_optional
33
4+ def self . exit_on_failure?
5+ false
6+ end
7+
48 attr_accessor :some_attribute
59 attr_writer :another_attribute
610 attr_reader :another_attribute
@@ -180,6 +184,10 @@ module Scripts
180184 class MyDefaults < Thor
181185 check_unknown_options!
182186
187+ def self . exit_on_failure?
188+ false
189+ end
190+
183191 namespace :default
184192 desc "cow" , "prints 'moo'"
185193 def cow
@@ -200,6 +208,10 @@ module Scripts
200208 end
201209
202210 class Arities < Thor
211+ def self . exit_on_failure?
212+ false
213+ end
214+
203215 desc "zero_args" , "takes zero args"
204216 def zero_args
205217 end
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ def foo(name)
5555 class Parent < Thor
5656 desc "child1" , "child1 description"
5757 subcommand "child1" , Child1
58+
59+ def self . exit_on_failure?
60+ false
61+ end
5862 end
5963 end
6064
Original file line number Diff line number Diff line change @@ -173,6 +173,10 @@ def boring(*args)
173173 def exec ( *args )
174174 [ options , args ]
175175 end
176+
177+ def self . exit_on_failure?
178+ false
179+ end
176180 end
177181
178182 it "passes remaining args to command when it encounters a non-option" do
@@ -223,6 +227,10 @@ def exec(*args)
223227 def checked ( *args )
224228 [ options , args ]
225229 end
230+
231+ def self . exit_on_failure?
232+ false
233+ end
226234 end
227235
228236 it "still accept options and arguments" do
@@ -285,6 +293,10 @@ def exec(*args)
285293 def boring ( *args )
286294 [ options , args ]
287295 end
296+
297+ def self . exit_on_failure?
298+ false
299+ end
288300 end
289301
290302 it "does not check the required option in the given command" do
@@ -716,4 +728,19 @@ def unknown(*args)
716728 expect ( MyScript . start ( %w( send ) ) ) . to eq ( true )
717729 end
718730 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+
719746end
You can’t perform that action at this time.
0 commit comments