Class: Extension::Commands::Create

Inherits:
ShopifyCli::SubCommand show all
Defined in:
lib/project_types/extension/commands/create.rb

Instance Attribute Summary

Attributes inherited from ShopifyCli::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ShopifyCli::SubCommand

call

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



29
30
31
32
33
34
35
36
37
# File 'lib/project_types/extension/commands/create.rb', line 29

def self.help
  "    Create a new app extension.\n      Usage: {{command:\#{ShopifyCli::TOOL_NAME} create extension <name>}}\n      Options:\n        {{command:--type=TYPE}} The type of extension you would like to create.\n        {{command:--name=NAME}} The name of your extension (50 characters).\u201D\n  HELP\nend\n"

Instance Method Details

#call(args, _) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/project_types/extension/commands/create.rb', line 11

def call(args, _)
  with_create_form(args) do |form|
    if Dir.exist?(form.directory_name)
      @ctx.abort(@ctx.message('create.errors.directory_exists', form.directory_name))
    end

    if form.type.create(form.directory_name, @ctx)
      ExtensionProject.write_cli_file(context: @ctx, type: form.type.identifier)
      ExtensionProject.write_env_file(context: @ctx, title: form.name)

      @ctx.puts(@ctx.message('create.ready_to_start', form.directory_name, form.name))
      @ctx.puts(@ctx.message('create.learn_more', form.type.name))
    else
      @ctx.puts(@ctx.message('create.try_again'))
    end
  end
end