Class: ShopifyCLI::Commands::Config::Feature

Inherits:
ShopifyCLI::Command::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 ShopifyCLI::Command::SubCommand

call

Methods inherited from ShopifyCLI::Command

call, call_help, check_node_version, check_ruby_version, check_version, #initialize, options, prerequisite_task, recommend_default_node_range, recommend_default_ruby_range, recommend_node, recommend_ruby, 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