lib/branch/name/cli.rb in branch-name-1.0.1.pre.beta vs lib/branch/name/cli.rb in branch-name-2.0.0.pre.beta
- old
+ new
@@ -7,11 +7,11 @@
require_relative 'clipable'
require_relative 'configurable'
require_relative 'exitable'
require_relative 'loadable'
require_relative 'locatable'
-require_relative 'nameable'
+require_relative 'normalizable'
require_relative 'projectable'
require_relative 'subcommands/config'
require_relative 'version'
module Branch
@@ -22,65 +22,70 @@
class CLI < ::Thor
include Clipable
include Exitable
include Loadable
include Locatable
- include Nameable
+ include Normalizable
include Projectable
class_option :debug, type: :boolean, default: false
class_option :verbose, type: :boolean, default: false
default_task :create
map %w[--version -v] => :version
- desc 'create [OPTIONS] TICKET [DESCRIPTION]', 'Formulate a branch name based on a ticket and optional description'
+ desc 'create [OPTIONS] DESCRIPTION [TICKET]', 'Formulate a branch name based on a ticket
+ description and optional ticket'
long_desc <<-LONG_DESC
NAME
\x5
- `branch-name create` -- will formulate a Git branch name based on the TICKET and optional DECRIPTION provided.
+ `branch-name create` -- will formulate a Git branch name based on the
+ DESCRIPTION and optional TICKET provided.
SYNOPSIS
\x5
- branch-name create [-d|-s|-p|-pL|-pF] TICKET [DESCRIPTION]
+ branch-name create [-l|-f|-d|-s|-p] 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.
+
\x5 -d: Forces the branch name to lower case.
- The default is --no-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 -pF: Used with the -p option. If -pF is specified, project files
- will be created in the PROJECT_LOCATION specified by the -pL option.
+ \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']}.
- \x5\x5 -pL PROJECT_LOCATION: Indicates where the project should be created.
+ \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)}".
LONG_DESC
method_option :downcase, type: :boolean, aliases: '-d'
method_option :separator, type: :string, aliases: '-s'
method_option :project, type: :boolean, aliases: '-p'
- method_option :project_location, type: :string, aliases: '-pL'
- method_option :project_files, type: :array, aliases: '-pF'
+ method_option :project_location, type: :string, aliases: '-l'
+ method_option :project_files, type: :array, aliases: '-f'
- def create(ticket, ticket_description = nil)
- if ticket.blank?
- say_error 'ticket is required', :red
+ def create(ticket_description, ticket = nil)
+ if ticket_description.blank?
+ say_error 'description is required', :red
exit 1
end
init_options_for! command: :create
- branch_name = "#{ticket} #{ticket_description}"
- branch_name = normalize_branch_name branch_name
+ branch_name = normalize_branch_name(ticket_description, ticket)
say "Branch name: #{branch_name}", :cyan
say "\"#{branch_name}\" has been copied to the clipboard!", :green if copy_to_clipboard branch_name