Module: Bashly::Script::Introspection::Flags
- Included in:
- Command
- Defined in:
- lib/bashly/script/introspection/flags.rb
Instance Method Summary collapse
-
#default_flags ⇒ Object
Returns an array of all the default Flags.
-
#flags ⇒ Object
Returns an array of Flags.
-
#global_flags? ⇒ Boolean
Returns true if this command’s flags should be considered as gloal flags, and cascade to subcommands.
-
#needy_flags ⇒ Object
Returns an array of all fpags that need other flags.
-
#public_flags ⇒ Object
Returns only flags that are not private.
-
#required_flags ⇒ Object
Returns an array of all the required Flags.
-
#short_flag_exist?(flag) ⇒ Boolean
Returns true if one of the flags matches the provided short code.
-
#visible_flags ⇒ Object
Returns only public flags, or both public and private flags if Settings.private_reveal_key is set.
-
#whitelisted_flags ⇒ Object
Returns an array of all the flags with a whitelist arg.
Instance Method Details
#default_flags ⇒ Object
Returns an array of all the default Flags
6 7 8 |
# File 'lib/bashly/script/introspection/flags.rb', line 6 def default_flags flags.select(&:default) end |
#flags ⇒ Object
Returns an array of Flags
11 12 13 14 15 16 17 |
# File 'lib/bashly/script/introspection/flags.rb', line 11 def flags return [] unless ['flags'] ['flags'].map do || Flag.new end end |
#global_flags? ⇒ Boolean
Returns true if this command’s flags should be considered as gloal flags, and cascade to subcommands
21 22 23 |
# File 'lib/bashly/script/introspection/flags.rb', line 21 def global_flags? flags.any? and commands.any? end |
#needy_flags ⇒ Object
Returns an array of all fpags that need other flags
26 27 28 |
# File 'lib/bashly/script/introspection/flags.rb', line 26 def needy_flags flags.select(&:needs) end |
#public_flags ⇒ Object
Returns only flags that are not private
31 32 33 |
# File 'lib/bashly/script/introspection/flags.rb', line 31 def public_flags flags.reject(&:private) end |
#required_flags ⇒ Object
Returns an array of all the required Flags
36 37 38 |
# File 'lib/bashly/script/introspection/flags.rb', line 36 def required_flags flags.select(&:required) end |
#short_flag_exist?(flag) ⇒ Boolean
Returns true if one of the flags matches the provided short code
41 42 43 |
# File 'lib/bashly/script/introspection/flags.rb', line 41 def short_flag_exist?(flag) flags.any? { |f| f.short == flag } end |
#visible_flags ⇒ Object
Returns only public flags, or both public and private flags if Settings.private_reveal_key is set
47 48 49 |
# File 'lib/bashly/script/introspection/flags.rb', line 47 def visible_flags Settings.private_reveal_key ? flags : public_flags end |
#whitelisted_flags ⇒ Object
Returns an array of all the flags with a whitelist arg
52 53 54 |
# File 'lib/bashly/script/introspection/flags.rb', line 52 def whitelisted_flags flags.select(&:allowed) end |