Sha256: b84b5a683e3314d4e3b0c742e664055476e98a0cd9914b5f574a10f585a80605

Contents?: true

Size: 823 Bytes

Versions: 26

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

module Script
  module Forms
    class AskApp < ShopifyCLI::Form
      attr_reader :app

      def ask
        apps = @xargs.fetch(:apps)

        unless @xargs[:acting_as_shopify_organization]
          apps = apps.select { |app| app["appType"] == "custom" }
        end

        raise Errors::NoExistingAppsError if apps.empty?

        @app =
          if apps.count > 1
            CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.app_select")) do |handler|
              apps.each do |app|
                handler.option(app["title"]) { app }
              end
            end
          else
            apps.first.tap do |app|
              ctx.puts(ctx.message("script.application.ensure_env.app", app["title"]))
            end
          end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
shopify-cli-2.18.1 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.18.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.17.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.16.1 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.16.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.15.6 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.15.5 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.15.4 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.15.3 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.15.2 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.15.1 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.15.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.14.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.13.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.12.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.11.2 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.11.1 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.11.0 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.10.2 lib/project_types/script/forms/ask_app.rb
shopify-cli-2.10.1 lib/project_types/script/forms/ask_app.rb