Sha256: a5d9f65d3544cd4a700e85072602eb83bbb38848c6261d97d99d17bca1d4ac9f

Contents?: true

Size: 815 Bytes

Versions: 34

Compression:

Stored size: 815 Bytes

Contents

# frozen_string_literal: true

module Script
  module Forms
    class AskOrg < ShopifyCLI::Form
      attr_reader :org

      BUSINESS_NAME = "businessName"
      ID = "id"

      def ask
        orgs = @xargs
        @org =
          if orgs.count == 1
            orgs.first.tap do |org|
              ctx.puts(ctx.message("script.application.ensure_env.organization", org[BUSINESS_NAME], org[ID]))
            end
          elsif orgs.count > 0
            CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.organization_select")) do |handler|
              orgs.each do |org|
                handler.option("#{org[BUSINESS_NAME]} (#{org[ID]})") { org }
              end
            end
          else
            raise Errors::NoExistingOrganizationsError
          end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
shopify-cli-2.25.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.24.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.23.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.22.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.21.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.20.1 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.20.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.19.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.18.1 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.18.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.17.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.16.1 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.16.0 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.15.6 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.15.5 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.15.4 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.15.3 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.15.2 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.15.1 lib/project_types/script/forms/ask_org.rb
shopify-cli-2.15.0 lib/project_types/script/forms/ask_org.rb