lib/branch/name/cli.rb in branch-name-3.5.1 vs lib/branch/name/cli.rb in branch-name-3.6.0
- old
+ new
@@ -42,53 +42,58 @@
`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|-x] DESCRIPTION [TICKET]
+ branch-name create [-i|-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
- are present. Run `branch-name config info` to determine what config files
- are present.
+ are present. Run `branch-name config info` to determine what config files
+ are present.
\x5 -d: Forces the branch name to lower case.
- The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['downcase']}.
+ The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['downcase']}.
- \x5\x5 -s SEPARATOR: Indicates the SEPARATOR that will be used to delimit tokens in the branch name.
- The default SEPARATOR is: '#{DEFAULT_BRANCH_NAME_OPTIONS['create']['separator']}'.
-
- \x5\x5 -p: Indicates that a project should be created.
- The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project']}.
-
\x5 -f: Used with the -p option. If -f is specified, project files
- will be created in the PROJECT_LOCATION specified by the -l option.
- The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project_files']}.
+ will be created in the PROJECT_LOCATION specified by the -l option.
+ The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project_files']}.
+ \x5 -i: Interactive. Used with the -p option. If -i is specified, you will
+ be prompted when creating project folders. If -i is not specified, you will
+ NOT be prompted when creating project folders.
+
\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)}".
+ 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\x5 -p: Indicates that a project should be created.
+ The default is: #{DEFAULT_BRANCH_NAME_OPTIONS['create']['project']}.
+
+ \x5\x5 -s SEPARATOR: Indicates the SEPARATOR that will be used to delimit tokens in the branch name.
+ The default SEPARATOR is: '#{DEFAULT_BRANCH_NAME_OPTIONS['create']['separator']}'.
+
\x5 -x FORMAT_STRING: This is a string that determines the format of the branch name
- that is formulated. The following is a list of required placeholders you must put
- in your format string to format the branch name: [%t, %d].
- \x5Where %t will be replaced by the ticket.
- \x5Where %d will be replaced by the ticket description.
- \x5The following is a list of optional placeholders you may put
- in your format string to format the branch name: [%u].
- \x5Where %u will be replaced with your username (`Etc.getlogin`, https://rubygems.org/gems/etc).
- \x5The default format string is: "#{DEFAULT_BRANCH_NAME_OPTIONS['create']['format_string']}".
+ that is formulated. The following is a list of required placeholders you must put
+ in your format string to format the branch name: [%t, %d].
+ \x5Where %t will be replaced by the ticket.
+ \x5Where %d will be replaced by the ticket description.
+ \x5The following is a list of optional placeholders you may put
+ in your format string to format the branch name: [%u].
+ \x5Where %u will be replaced with your username (`Etc.getlogin`, https://rubygems.org/gems/etc).
+ \x5The default format string 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'
+ method_option :interactive, type: :boolean, aliases: '-i'
def create(ticket_description, ticket = nil)
if ticket_description.blank?
say_error 'description is required', ERROR
exit 1
@@ -106,14 +111,16 @@
if options[:project]
project_folder_name = project_folder_name_from(branch_name) do |error|
say_error error.message
exit 1
end
- 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
+ if options[: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