Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Feature Sets

Kevin O'Sullivan edited this page Jun 29, 2021 · 2 revisions

ShopifyCli::Feature

The ShopifyCli::Feature class can be used to check if a feature is enabled to optionally enable certain codepaths. These can be enabled and disabled by calling shopify config feature [feature_name] --enable/--disable

So you can have code that looks like

@ctx.puts("debug info") if ShopifyCli::Feature.enabled?(:debug_outputs)

And to get it to work, call

shopify config feature :debug_outputs --enable

These will persist until --disable is called

ShopifyCli::Feature.enable

ShopifyCli::Feature.enable(feature) will enable a feature in the CLI.

Parameters

  • feature - a symbol representing the flag to be enabled

ShopifyCli::Feature.disable

ShopifyCli::Feature.disable(feature) Will disable a feature in the CLI.

Parameters

  • feature - a symbol representing the flag to be disabled

ShopifyCli::Feature.enabled?

ShopifyCli::Feature.enabled?(feature) 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.

ShopifyCli::Feature::Set

ShopifyCli::Feature::Set is included in each command and project type. It allows you to optionally hide and show commands and projects.

hidden_feature

hidden_feature(feature_set: []) Will hide a the object the method is being called on (project_type or command) and will be able to be optionally shown when enabled

Parameters

  • feature_set - A symbol or array of symbols that represent a feature set.

Example

project = ShopifyCli::Project.current
see source

module Foo
  class Command < ShopifyCli::ProjectCommands
    hidden_feature(feature_set: :foo_project)
  end
end

Clone this wiki locally