Class: Script::Commands::Enable

Inherits:
ShopifyCli::Command show all
Defined in:
lib/project_types/script/commands/enable.rb

Instance Attribute Summary

Attributes inherited from ShopifyCli::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ShopifyCli::Command

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

Methods included from ShopifyCli::Feature::Set

#hidden?, #hidden_feature

Constructor Details

This class inherits a constructor from ShopifyCli::Command

Class Method Details

.helpObject



41
42
43
# File 'lib/project_types/script/commands/enable.rb', line 41

def self.help
  ShopifyCli::Context.message('script.enable.help', ShopifyCli::TOOL_NAME)
end

Instance Method Details

#call(_args, _name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/project_types/script/commands/enable.rb', line 13

def call(_args, _name)
  ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
  project = ScriptProject.current
  api_key = project.env[:api_key]
  shop_domain = project.env[:shop]

  Layers::Application::EnableScript.call(
    ctx: @ctx,
    api_key: api_key,
    shop_domain: shop_domain,
    configuration: acquire_configuration(**slice(options.flags, :config_file, :config_props)),
    extension_point_type: project.extension_point_type,
    title: project.script_name
  )
  @ctx.puts(@ctx.message(
    'script.enable.script_enabled',
    api_key: api_key,
    shop_domain: shop_domain,
    type: project.extension_point_type.capitalize,
    title: project.script_name
  ))
  @ctx.puts(@ctx.message('script.enable.info'))
rescue Errors::InvalidConfigYAMLError => e
  UI::ErrorHandler.pretty_print_and_raise(e)
rescue StandardError => e
  UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.enable.error.operation_failed'))
end