Class: Extension::Forms::Create

Inherits:
ShopifyCLI::Form show all
Defined in:
lib/project_types/extension/forms/create.rb

Defined Under Namespace

Classes: ExtensionProjectDetails

Instance Attribute Summary collapse

Attributes inherited from ShopifyCLI::Form

#ctx, #xargs

Instance Method Summary collapse

Methods inherited from ShopifyCLI::Form

ask, flag_arguments, #initialize, positional_arguments

Constructor Details

This class inherits a constructor from ShopifyCLI::Form

Instance Attribute Details

#appObject

Returns the value of attribute app.



8
9
10
# File 'lib/project_types/extension/forms/create.rb', line 8

def app
  @app
end

Instance Method Details

#askObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/project_types/extension/forms/create.rb', line 23

def ask
  ShopifyCLI::Result.wrap(ExtensionProjectDetails.new)
    .then(&Questions::AskApp.new(ctx: ctx, api_key: api_key))
    .then(&Questions::AskType.new(ctx: ctx, type: type))
    .then(&Questions::AskTemplate.new(ctx: ctx, template: template))
    .then(&Questions::AskName.new(ctx: ctx, name: name))
    .unwrap { |e| raise e }
    .tap do |project_details|
      ctx.abort(ctx.message("create.incomplete_configuration")) unless project_details.complete?

      self.app = project_details.app
      self.type = project_details.type
      self.template = project_details.template
      self.name = project_details.name
    end
end

#directory_nameObject



40
41
42
# File 'lib/project_types/extension/forms/create.rb', line 40

def directory_name
  name.strip.gsub(/( )/, "_").downcase
end