solara/lib/solara.rb in solara-0.2.0 vs solara/lib/solara.rb in solara-0.2.1
- old
+ new
@@ -52,10 +52,14 @@
def init
brand_key = options['brand_key']
brand_name = options['brand_name']
input_platform = options['platform']
+ if !brand_key || !brand_name
+ Solara.logger.warn('To set up Solara, we need to onboard an initial brand. Please provide the following details for your first brand:')
+ end
+
brand_key = validate_brand_key(brand_key, ignore_brand_check: true)
brand_name = validate_brand_name(brand_name)
platform = if !input_platform.nil?
input_platform
@@ -64,11 +68,11 @@
end
platform = platform.to_s.downcase
SolaraSettingsManager.instance.platform = platform
- SolaraManager.new.init(platform, brand_key, brand_name)
+ SolaraManager.new.init(brand_key, brand_name)
end
desc "status", "Check the current status of Solara. The results may include information about the brand's current standing, the list of brands, and additional details."
def status
@@ -140,11 +144,11 @@
check_project_health
brand_key = options['brand_key']
brand_key = validate_brand_key(brand_key)
begin
SolaraManager.new.switch(brand_key)
- rescue StandardError => e
+ rescue Issue => e
Solara.logger.fatal("Switching to #{brand_key} failed.")
exit 1
end
end
@@ -190,20 +194,20 @@
def validate_brand_key(brand_key, ignore_if_nil: false, ignore_brand_check: false, message: nil)
if ignore_if_nil && brand_key.nil?
return brand_key
end
- if brand_key.nil? || brand_key.empty? || (!ignore_brand_check && BrandsManager.instance.find(brand_key).nil?)
+ if brand_key.nil? || brand_key.empty? || (!ignore_brand_check && !BrandsManager.instance.exists(brand_key))
message = message || (brand_key.nil? || brand_key.empty? ? "Please enter brand key: " : "Please enter existing brand key: ")
brand_key = TerminalInputManager.new.get_validated(message) do |input|
# Validate that it starts with a letter and contains no spaces
unless input.match?(/^[a-zA-Z][\S]*$/)
Solara.logger.failure("Invalid brand key. It must start with at least a letter and contain no spaces.")
next false # Use `next` to continue the loop
end
# Check if the brand exists in the list
- if !ignore_brand_check && BrandsManager.instance.find(input).nil?
+ if !ignore_brand_check && !BrandsManager.instance.exists(input)
Solara.logger.failure("Brand key does not exist.")
next false # Use `next` to continue the loop
end
true # Valid input and brand exists
\ No newline at end of file