Sha256: 0ab35602c5cc9b08dd9c6f343ad32c79bc2d65ebb3ae39fd6faa308f96fe523d

Contents?: true

Size: 785 Bytes

Versions: 7

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

module Script
  module Forms
    class Create < ScriptForm
      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

7 entries across 7 versions & 1 rubygems

Version Path
shopify-cli-1.0.5 lib/project_types/script/forms/create.rb
shopify-cli-1.0.4 lib/project_types/script/forms/create.rb
shopify-cli-1.0.3 lib/project_types/script/forms/create.rb
shopify-cli-1.0.2 lib/project_types/script/forms/create.rb
shopify-cli-1.0.1 lib/project_types/script/forms/create.rb
shopify-cli-1.0.0 lib/project_types/script/forms/create.rb
shopify-cli-0.9.3 lib/project_types/script/forms/create.rb