File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -180,9 +180,6 @@ module Cling
180180 # This has access to the parsed arguments and options from the command line. This is useful if
181181 # you want to implement checks for specific flags outside of the main `run` method, such as
182182 # `-v`/`--version` flags or `-h`/`--help` flags.
183- #
184- # Accepts a `Bool` or `nil` argument as a return to specify whether the command should continue
185- # to run once finished (`true` or `nil` to continue, `false` to stop).
186183 def pre_run (arguments : Arguments , options : Options ) : Bool ?
187184 end
188185
Original file line number Diff line number Diff line change @@ -50,7 +50,10 @@ module Cling::Executor
5050 end
5151
5252 begin
53- resolved_command.pre_run executed.parsed_arguments, executed.parsed_options
53+ deprecation_helper(
54+ resolved_command,
55+ resolved_command.pre_run(executed.parsed_arguments, executed.parsed_options)
56+ )
5457 rescue ex : ExitProgram
5558 return handle_exit ex
5659 rescue ex
@@ -69,6 +72,14 @@ module Cling::Executor
6972 end
7073 end
7174
75+ private def self.deprecation_helper (type : T , value : Bool ?) : Nil forall T
76+ {% T .warning " #{ T } #pre_run : Bool? is deprecated. Use `pre_run(arguments : Arguments, options : Options) : Nil` instead" % }
77+ raise ExitProgram .new 1 if value == false
78+ end
79+
80+ private def self.deprecation_helper (type : T , value : Nil ) : Nil forall T
81+ end
82+
7283 private def self.resolve_command (command : Command , results : Array (Parser ::Result )) : Command ?
7384 arguments = results.select { |r | r.kind.argument? && ! r.string? }
7485 return command if arguments.empty? || command.children.empty?
You can’t perform that action at this time.
0 commit comments