Class: ShopifyCLI::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_cli/feature.rb

Overview

ShopifyCLI::Feature contains the logic to hide and show features across the CLI These features can be either commands or project types currently.

Feature flags will persist between runs so if the flag is enabled or disabled, it will still be in that same state on the next cli invocation.

Defined Under Namespace

Modules: Set

Constant Summary collapse

SECTION =
"features"

Class Method Summary collapse

Class Method Details

.disable(feature) ⇒ Object

will disable a feature in the CLI.

#### Parameters

  • ‘feature` - a symbol representing the flag to be disabled



71
72
73
# File 'lib/shopify_cli/feature.rb', line 71

def disable(feature)
  set(feature, false)
end

.enable(feature) ⇒ Object

will enable a feature in the CLI.

#### Parameters

  • ‘feature` - a symbol representing the flag to be enabled



61
62
63
# File 'lib/shopify_cli/feature.rb', line 61

def enable(feature)
  set(feature, true)
end

.enabled?(feature) ⇒ Boolean

will check if the feature has been enabled

#### Parameters

  • ‘feature` - a symbol representing a flag that the status should be requested

#### Returns

  • ‘is_enabled` - will be true if the feature has been enabled.

Returns:

  • (Boolean)


85
86
87
88
# File 'lib/shopify_cli/feature.rb', line 85

def enabled?(feature)
  return false if feature.nil?
  ShopifyCLI::Config.get_bool(SECTION, feature.to_s)
end

.set(feature, value) ⇒ Object



90
91
92
# File 'lib/shopify_cli/feature.rb', line 90

def set(feature, value)
  ShopifyCLI::Config.set(SECTION, feature.to_s, value)
end