Class: ShopifyCli::Commands::Config::Feature

Inherits:
SubCommand show all
Defined in:
lib/shopify-cli/commands/config.rb

Instance Attribute Summary

Attributes inherited from ShopifyCli::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SubCommand

call

Methods inherited from ShopifyCli::Command

call, call_help, #initialize, options, prerequisite_task, run_prerequisites, subcommand, subcommand_registry

Methods included from Feature::Set

#hidden?, #hidden_feature

Constructor Details

This class inherits a constructor from ShopifyCli::Command

Class Method Details

.helpObject



20
21
22
# File 'lib/shopify-cli/commands/config.rb', line 20

def self.help
  ShopifyCli::Context.message('core.config.feature.help', ShopifyCli::TOOL_NAME)
end

Instance Method Details

#call(args, _name) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/shopify-cli/commands/config.rb', line 30

def call(args, _name)
  feature_name = args.shift
  return @ctx.puts(@ctx.message('core.config.help', ShopifyCli::TOOL_NAME)) if feature_name.nil?
  is_enabled = ShopifyCli::Feature.enabled?(feature_name)
  if options.flags[:action] == 'disable' && is_enabled
    ShopifyCli::Feature.disable(feature_name)
    @ctx.puts(@ctx.message('core.config.feature.disabled', feature_name))
  elsif options.flags[:action] == 'enable' && !is_enabled
    ShopifyCli::Feature.enable(feature_name)
    @ctx.puts(@ctx.message('core.config.feature.enabled', feature_name))
  elsif is_enabled
    @ctx.puts(@ctx.message('core.config.feature.is_enabled', feature_name))
  else
    @ctx.puts(@ctx.message('core.config.feature.is_disabled', feature_name))
  end
end