Class: Tabry::CLI::Base
- Inherits:
-
Object
- Object
- Tabry::CLI::Base
- Defined in:
- lib/tabry/cli/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#internals ⇒ Object
readonly
Returns the value of attribute internals.
Class Method Summary collapse
- .after_action(*method_names, only: nil, except: nil, &blk) ⇒ Object
- .before_action(*method_names, only: nil, except: nil, &blk) ⇒ Object
- .sub_route(*prefixes, to:, **opts) ⇒ Object
Instance Method Summary collapse
-
#initialize(flags, args, named_args, internals) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(flags, args, named_args, internals) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 |
# File 'lib/tabry/cli/base.rb', line 11 def initialize(flags, args, named_args, internals) @args = ArgProxy.new(args, named_args) @flags = FlagProxy.new(flags) @internals = internals end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/tabry/cli/base.rb', line 9 def args @args end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
9 10 11 |
# File 'lib/tabry/cli/base.rb', line 9 def flags @flags end |
#internals ⇒ Object (readonly)
Returns the value of attribute internals.
9 10 11 |
# File 'lib/tabry/cli/base.rb', line 9 def internals @internals end |
Class Method Details
.after_action(*method_names, only: nil, except: nil, &blk) ⇒ Object
24 25 26 27 28 |
# File 'lib/tabry/cli/base.rb', line 24 def self.after_action(*method_names, only: nil, except: nil, &blk) [*method_names, blk].compact.each do |met| (@after_actions ||= []) << [met, { only: only, except: except }] end end |
.before_action(*method_names, only: nil, except: nil, &blk) ⇒ Object
30 31 32 33 34 |
# File 'lib/tabry/cli/base.rb', line 30 def self.before_action(*method_names, only: nil, except: nil, &blk) [*method_names, blk].compact.each do |met| (@before_actions ||= []) << [met, { only: only, except: except }] end end |
.sub_route(*prefixes, to:, **opts) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/tabry/cli/base.rb', line 17 def self.sub_route(*prefixes, to:, **opts) prefixes.map(&:to_s).each do |prefix| (@sub_route_clis ||= {})[prefix] = to (@sub_route_clis_opts ||= {})[prefix] = opts end end |