Sha256: 0a35a76c98b54b8f7ab81b5281276242d347e83a00a372efa06560db16ff7f4d

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

module Theme
  module Forms
    class Connect < ShopifyCli::Form
      attr_accessor :name
      flag_arguments :themeid, :password, :store, :env

      def ask
        self.store ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_store"), allow_empty: false)
        ctx.puts(ctx.message("theme.forms.connect.private_app", store))
        self.password ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_password"), allow_empty: false)

        errors = []
        errors << "store" if store.strip.empty?
        errors << "password" if password.strip.empty?
        ctx.abort(ctx.message("theme.forms.errors", errors.join(", ").capitalize)) unless errors.empty?

        self.themeid, self.name = ask_theme(store: store, password: password, themeid: themeid)
      end

      private

      def ask_theme(store:, password:, themeid:)
        themes = Themekit.query_themes(@ctx, store: store, password: password)

        themeid ||= CLI::UI::Prompt.ask("Select theme") do |handler|
          themes.each do |name, id|
            handler.option(name) { id }
          end
        end
        [themeid, themes.key(themeid.to_i)]
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify-cli-1.14.0 lib/project_types/theme/forms/connect.rb
shopify-cli-1.13.1 lib/project_types/theme/forms/connect.rb
shopify-cli-1.13.0 lib/project_types/theme/forms/connect.rb
shopify-cli-1.12.0 lib/project_types/theme/forms/connect.rb
shopify-cli-1.11.0 lib/project_types/theme/forms/connect.rb
shopify-cli-1.10.0 lib/project_types/theme/forms/connect.rb
shopify-cli-1.9.1 lib/project_types/theme/forms/connect.rb
shopify-cli-1.9.0 lib/project_types/theme/forms/connect.rb
shopify-cli-1.8.0 lib/project_types/theme/forms/connect.rb
shopify-cli-1.7.1 lib/project_types/theme/forms/connect.rb
shopify-cli-1.7.0 lib/project_types/theme/forms/connect.rb