Sha256: 265a114bca557db0e60ae4dd551b50adcce63eaca703d51c1e0e6998a0eb438b

Contents?: true

Size: 791 Bytes

Versions: 9

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

module Script
  module Forms
    class Create < ShopifyCli::Form
      flag_arguments :extension_point, :name

      def ask
        self.name = valid_name
        self.extension_point ||= ask_extension_point
      end

      private

      def ask_extension_point
        CLI::UI::Prompt.ask(
          @ctx.message('script.forms.create.select_extension_point'),
          options: Script::Layers::Application::ExtensionPoints.types
        )
      end

      def ask_name
        CLI::UI::Prompt.ask(@ctx.message('script.forms.create.script_name'))
      end

      def valid_name
        n = (name || ask_name).downcase.gsub(' ', '_')
        return n if n.match?(/^[0-9A-Za-z_-]*$/)
        raise Errors::InvalidScriptNameError
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shopify-cli-1.5.0 lib/project_types/script/forms/create.rb
shopify-cli-1.4.1 lib/project_types/script/forms/create.rb
shopify-cli-1.4.0 lib/project_types/script/forms/create.rb
shopify-cli-1.3.1 lib/project_types/script/forms/create.rb
shopify-cli-1.3.0 lib/project_types/script/forms/create.rb
shopify-cli-1.2.0 lib/project_types/script/forms/create.rb
shopify-cli-1.1.2 lib/project_types/script/forms/create.rb
shopify-cli-1.1.1 lib/project_types/script/forms/create.rb
shopify-cli-1.1.0 lib/project_types/script/forms/create.rb