Method: CLIApp::Action#call
- Defined in:
- lib/cliapp.rb
#call(*args, **opts) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cliapp.rb', line 35 def call(*args, **opts) #; [!pc2hw] raises error when fewer arguments. n_min, n_max = Util.arity_of_proc(@block) args.length >= n_min or raise ActionTooFewArgsError, "Too few arguments." #; [!6vdhh] raises error when too many arguments. n_max == nil || args.length <= n_max or raise ActionTooManyArgsError, "Too many arguments." #; [!7n4hs] invokes action block with args and kwargs. if opts.empty? # for Ruby < 2.7 @block.call(*args) # for Ruby < 2.7 else @block.call(*args, **opts) end end |