Class: Branch::Name::CLI
- Includes:
- Clipable, Exitable, Loadable, Locatable, Projectable, TaskDefaultable
- Defined in:
- lib/branch/name/cli.rb
Overview
The ‘branch-name` command.
Constant Summary
Constants included from Normalizable
Normalizable::BRANCH_NAME_REGEX, Normalizable::DEFAULT_PROJECT_FOLDER_TOKEN_SEPARATOR, Normalizable::PROJECT_FOLDER_REGEX, Normalizable::PROJECT_FOLDER_TOKEN_SEPARATORS
Constants included from Configurable
Branch::Name::Configurable::CONFIG_FILENAME, Branch::Name::Configurable::DEFAULT_BRANCH_NAME_OPTIONS
Constants included from Colorizable
Branch::Name::Colorizable::ABORTED, Branch::Name::Colorizable::ERROR, Branch::Name::Colorizable::SUCCESS, Branch::Name::Colorizable::WARNING
Class Method Summary collapse
Instance Method Summary collapse
-
#create(ticket_description, ticket = nil) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #version ⇒ Object
Methods included from TaskDefaultable
Methods included from Projectable
#create_project!, #create_project_files!, #project_folder_for
Methods included from Normalizable
#normalize_branch_name, #project_folder_name_from
Methods included from Locatable
global_folder?, home_folder, local_folder, project_folder, temp_folder
Methods included from Loadable
Methods included from Configurable
#create_config_file, #create_global_config_file!, #create_local_config_file!, #delete_global_config_file!, #delete_local_config_file!, #global_config_file, #global_config_file?, #local_config_file, #local_config_file?, #print_global_config_file, #print_local_config_file
Methods included from Exitable
Methods included from Clipable
copy_to_clipboard, copy_to_clipboard_macos, copy_to_clipboard_windows, copy_to_clipboard_with
Class Method Details
.exit_on_failure? ⇒ Boolean
33 34 35 |
# File 'lib/branch/name/cli.rb', line 33 def exit_on_failure? true end |
Instance Method Details
#create(ticket_description, ticket = nil) ⇒ Object
rubocop:disable Metrics/MethodLength
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/branch/name/cli.rb', line 101 def create(ticket_description, ticket = nil) # rubocop:disable Metrics/MethodLength , = command: :create self. = branch_name = BranchNameService.new(description: ticket_description, ticket: ticket, options: ).call say "Branch name: \"#{branch_name}\"", :cyan say "Branch name \"#{branch_name}\" has been copied to the clipboard!", SUCCESS if copy_to_clipboard branch_name if [:interactive] && ![:project] say 'Ignored: -i is only used with projects (-p).', WARNING end interactive_default = ['interactive'] [:interactive] = interactive_default if [:interactive].nil? if [:project] project_folder_name = validate_and_create_project_folder_name_from! branch_name if [:interactive] project_folder = project_folder_for branch_name unless yes? "Create project for branch \"#{branch_name}\" " \ "in folder \"#{project_folder}\" (y/n)?", :cyan say 'Aborted.', ABORTED return end end say "Project folder name: \"#{project_folder_name}\"", :cyan create_project!(project_folder_name) end rescue ArgumentError => e say_error e., ERROR exit 1 end |