Class: Theme::Command::Open
Instance Attribute Summary
#ctx, #options
Class Method Summary
collapse
Instance Method Summary
collapse
#shop
call
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
#hidden?, #hidden_feature
Instance Method Details
#call(_args, _name) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/project_types/theme/commands/open.rb', line 21
def call(_args, _name)
theme = find_theme(**options.flags)
@ctx.puts(@ctx.message("theme.open.details", theme.name, theme.preview_url, theme.editor_url))
if options.flags[:editor]
@ctx.open_browser_url!(theme.editor_url)
else
@ctx.open_browser_url!(theme.preview_url)
end
end
|
#development_theme ⇒ Object
49
50
51
52
|
# File 'lib/project_types/theme/commands/open.rb', line 49
def development_theme
theme = ShopifyCLI::Theme::DevelopmentTheme.find(@ctx)
theme || not_found_error("development")
end
|
#find_theme(theme: nil, live: nil, development: nil, **_args) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/project_types/theme/commands/open.rb', line 36
def find_theme(theme: nil, live: nil, development: nil, **_args)
return theme_by_identifier(theme) if theme
return live_theme if live
return development_theme if development
select_theme
end
|
#live_theme ⇒ Object
54
55
56
|
# File 'lib/project_types/theme/commands/open.rb', line 54
def live_theme
ShopifyCLI::Theme::Theme.live(@ctx)
end
|
#not_found_error(identifier) ⇒ Object
58
59
60
|
# File 'lib/project_types/theme/commands/open.rb', line 58
def not_found_error(identifier)
@ctx.abort(@ctx.message("theme.open.theme_not_found", identifier))
end
|
#select_theme ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/project_types/theme/commands/open.rb', line 62
def select_theme
form = Forms::Select.ask(
@ctx,
[],
title: @ctx.message("theme.open.select", shop),
root: nil
)
form&.theme
end
|
#theme_by_identifier(identifier) ⇒ Object
44
45
46
47
|
# File 'lib/project_types/theme/commands/open.rb', line 44
def theme_by_identifier(identifier)
theme = ShopifyCLI::Theme::Theme.find_by_identifier(@ctx, identifier: identifier)
theme || not_found_error(identifier)
end
|