lib/branch/name/cli.rb in branch-name-2.1.0 vs lib/branch/name/cli.rb in branch-name-2.2.0

- old
+ new

@@ -41,11 +41,11 @@ `branch-name create` -- will formulate a Git branch name based on the DESCRIPTION and optional TICKET provided. SYNOPSIS \x5 - branch-name create [-l|-f|-d|-s|-p] DESCRIPTION [TICKET] + branch-name create [-l|-f|-d|-s|-p|-x] DESCRIPTION [TICKET] \x5 The following options are available: \x5 NOTE: Default option values will be overidden if .branch-name config files @@ -67,13 +67,21 @@ \x5\x5 -l PROJECT_LOCATION: Indicates where the project should be created. A "project" is a folder that is created in the PROJECT_LOCATION specified, whose name is equivalent to the branch name that is formulated. The default is: "#{Locatable.project_folder(options: options)}". + + \x5 -x FORMAT_STRING: This is a string that determines the format of the branch name + that is formulated. The following are a list of required placeholders you must put + in your format string to format the brach name: [%t, %d]. + \x5Where %t will be replaced by the ticket. + \x5Where %d will be replaced by the ticket description. + \x5The default is: "#{DEFAULT_BRANCH_NAME_OPTIONS['create']['format_string']}". LONG_DESC method_option :downcase, type: :boolean, aliases: '-d' method_option :separator, type: :string, aliases: '-s' + method_option :format_string, type: :string, aliases: '-x' method_option :project, type: :boolean, aliases: '-p' method_option :project_location, type: :string, aliases: '-l' method_option :project_files, type: :array, aliases: '-f' def create(ticket_description, ticket = nil) @@ -82,10 +90,13 @@ exit 1 end init_options_for! command: :create - branch_name = normalize_branch_name(ticket_description, ticket) + branch_name = normalize_branch_name(ticket_description, ticket) do |error| + say_error error.message + exit 1 + end say "Branch name: #{branch_name}", :cyan say "\"#{branch_name}\" has been copied to the clipboard!", :green if copy_to_clipboard branch_name