Class: Script::Commands::Create
- Inherits:
-
ShopifyCli::SubCommand
- Object
- CLI::Kit::BaseCommand
- ShopifyCli::Command
- ShopifyCli::SubCommand
- Script::Commands::Create
- Defined in:
- lib/project_types/script/commands/create.rb
Instance Attribute Summary
Attributes inherited from ShopifyCli::Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ShopifyCli::SubCommand
Methods inherited from ShopifyCli::Command
call, call_help, #initialize, options, prerequisite_task, run_prerequisites, subcommand, subcommand_registry
Methods included from ShopifyCli::Feature::Set
Constructor Details
This class inherits a constructor from ShopifyCli::Command
Class Method Details
.help ⇒ Object
36 37 38 39 |
# File 'lib/project_types/script/commands/create.rb', line 36 def self.help allowed_values = Script::Layers::Application::ExtensionPoints.types.map { |type| "{{cyan:#{type}}}" } ShopifyCli::Context.('script.create.help', ShopifyCli::TOOL_NAME, allowed_values.join(', ')) end |
Instance Method Details
#call(args, _name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/project_types/script/commands/create.rb', line 11 def call(args, _name) language = 'ts' cur_dir = @ctx.root form = Forms::Create.ask(@ctx, args, .flags) return @ctx.puts(self.class.help) if form.nil? unless !form.name.empty? && form.extension_point && ScriptProject::SUPPORTED_LANGUAGES.include?(language) return @ctx.puts(self.class.help) end project = Layers::Application::CreateScript.call( ctx: @ctx, language: language, script_name: form.name, extension_point_type: form.extension_point ) @ctx.puts(@ctx.('script.create.change_directory_notice', project.script_name)) rescue Script::Errors::ScriptProjectAlreadyExistsError => e UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.('script.create.error.operation_failed')) rescue StandardError => e ScriptProject.cleanup(ctx: @ctx, script_name: form.name, root_dir: cur_dir) if form UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.('script.create.error.operation_failed')) end |