Class: ShopifyCLI::Options
- Inherits:
-
Object
- Object
- ShopifyCLI::Options
- Includes:
- SmartProperties
- Defined in:
- lib/shopify_cli/options.rb
Direct Known Subclasses
Extension::Command::Check::CheckOptions, Theme::Command::Check::Options
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#subcommand ⇒ Object
readonly
Returns the value of attribute subcommand.
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #parse(options_block, args) ⇒ Object
- #parse_flags(block) ⇒ Object
- #parser ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
11 12 13 14 |
# File 'lib/shopify_cli/options.rb', line 11 def initialize @flags = {} @help = false end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
9 10 11 |
# File 'lib/shopify_cli/options.rb', line 9 def flags @flags end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
9 10 11 |
# File 'lib/shopify_cli/options.rb', line 9 def help @help end |
#subcommand ⇒ Object (readonly)
Returns the value of attribute subcommand.
9 10 11 |
# File 'lib/shopify_cli/options.rb', line 9 def subcommand @subcommand end |
Instance Method Details
#parse(options_block, args) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/shopify_cli/options.rb', line 16 def parse(, args) @args = args if .respond_to?(:call) && args parse_flags() else parser.permute!(@args) end @args end |
#parse_flags(block) ⇒ Object
26 27 28 29 |
# File 'lib/shopify_cli/options.rb', line 26 def parse_flags(block) block.call(parser, @flags) parser.permute!(@args) end |
#parser ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/shopify_cli/options.rb', line 31 def parser @parser ||= begin opt = OptionParser.new opt.on("--help", "-h", Context.("core.options.help_text")) do |v| @help = v end end end |