Class: ShopifyCLI::Commands::Switch
- Inherits:
-
ShopifyCLI::Command
- Object
- CLI::Kit::BaseCommand
- ShopifyCLI::Command
- ShopifyCLI::Commands::Switch
- Defined in:
- lib/shopify_cli/commands/switch.rb
Instance Attribute Summary
Attributes inherited from ShopifyCLI::Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ShopifyCLI::Command
call, call_help, check_node_version, check_ruby_version, check_version, #initialize, options, prerequisite_task, recommend_default_node_range, recommend_default_ruby_range, recommend_node, recommend_ruby, run_prerequisites, subcommand, subcommand_registry
Methods included from Feature::Set
Constructor Details
This class inherits a constructor from ShopifyCLI::Command
Class Method Details
.help ⇒ Object
34 35 36 |
# File 'lib/shopify_cli/commands/switch.rb', line 34 def self.help ShopifyCLI::Context.("core.switch.help", ShopifyCLI::TOOL_NAME) end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shopify_cli/commands/switch.rb', line 12 def call(*) if Shopifolk.acting_as_shopify_organization? @ctx.puts(@ctx.("core.switch.disabled_as_shopify_org")) return end shop = if .flags[:shop] Login.validate_shop(.flags[:shop], context: @ctx) elsif (org_id = DB.get(:organization_id)) res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx, organization_id: org_id) res[:shop_domain] else AdminAPI.get_shop_or_abort(@ctx) res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx) res[:shop_domain] end DB.set(shop: shop) IdentityAuth.new(ctx: @ctx).reauthenticate @ctx.puts(@ctx.("core.switch.success", shop)) end |