Sha256: 4fde65d932ed0ff681686e800968b49348dd39ec71961a8e6a13309cabcb8c82

Contents?: true

Size: 937 Bytes

Versions: 57

Compression:

Stored size: 937 Bytes

Contents

require "shopify_cli"

module ShopifyCLI
  module Commands
    class Whoami < ShopifyCLI::Command
      def call(_args, _name)
        shop = ShopifyCLI::DB.get(:shop)
        org_id = ShopifyCLI::DB.get(:organization_id)
        org = ShopifyCLI::PartnersAPI::Organizations.fetch(@ctx, id: org_id) unless org_id.nil?

        output = if shop.nil? && org.nil?
          @ctx.message("core.whoami.not_logged_in", ShopifyCLI::TOOL_NAME)
        elsif !shop.nil? && org.nil?
          @ctx.message("core.whoami.logged_in_shop_only", shop)
        elsif shop.nil? && !org.nil?
          @ctx.message("core.whoami.logged_in_partner_only", org["businessName"])
        else
          @ctx.message("core.whoami.logged_in_partner_and_shop", shop, org["businessName"])
        end
        @ctx.puts(output)
      end

      def self.help
        ShopifyCLI::Context.message("core.whoami.help", ShopifyCLI::TOOL_NAME)
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.35.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.34.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.33.1 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.33.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.32.1 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.32.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.31.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.30.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.29.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.28.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.27.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.26.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.25.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.24.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.23.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.22.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.21.0 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.20.1 lib/shopify_cli/commands/whoami.rb
shopify-cli-2.20.0 lib/shopify_cli/commands/whoami.rb