code cleanup
This commit is contained in:
@@ -13,6 +13,15 @@ module Feature
|
|||||||
def initialize (argv)
|
def initialize (argv)
|
||||||
@argv = argv
|
@argv = argv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def valid?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def help
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,31 +7,29 @@ require_relative './branch'
|
|||||||
module Feature
|
module Feature
|
||||||
|
|
||||||
class Commander
|
class Commander
|
||||||
attr_reader :argv
|
attr_reader :subcommand
|
||||||
|
|
||||||
def initialize (argv)
|
def initialize (argv)
|
||||||
@argv = argv
|
@subcommand = case argv[0]
|
||||||
|
when "start" then Feature::Start.new(argv)
|
||||||
|
when "end" then Feature::End.new(argv)
|
||||||
|
when "rebase" then Feature::Rebase.new(argv)
|
||||||
|
when "merge" then Feature::MergeTo.new(argv)
|
||||||
|
else Feature::Branch.new(argv)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid?
|
def valid?
|
||||||
true
|
subcommand.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def help
|
def help
|
||||||
exit
|
subcommand.help
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
command = case argv[0]
|
subcommand.execute
|
||||||
when "start" then Feature::Start.new(argv)
|
|
||||||
when "end" then Feature::End.new(argv)
|
|
||||||
when "rebase" then Feature::Rebase.new(argv)
|
|
||||||
when "merge" then Feature::MergeTo.new(argv)
|
|
||||||
else Feature::Branch.new(argv)
|
|
||||||
end
|
|
||||||
command.execute
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,9 +3,18 @@ require_relative './base'
|
|||||||
module Feature
|
module Feature
|
||||||
|
|
||||||
class End < Feature::Base
|
class End < Feature::Base
|
||||||
def execute
|
def valid?
|
||||||
error "USAGE: feature end" unless argv.size == 1
|
argv.size == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def help
|
||||||
|
puts
|
||||||
|
puts "USAGE: feature end"
|
||||||
|
puts
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
parts = parse_branch(current_branch)
|
parts = parse_branch(current_branch)
|
||||||
|
|
||||||
standard_branch = parts[:standard]
|
standard_branch = parts[:standard]
|
||||||
|
|||||||
@@ -3,6 +3,17 @@ require_relative './base'
|
|||||||
module Feature
|
module Feature
|
||||||
|
|
||||||
class MergeTo < Feature::Base
|
class MergeTo < Feature::Base
|
||||||
|
def valid?
|
||||||
|
[1,2].include? argv.size
|
||||||
|
end
|
||||||
|
|
||||||
|
def help
|
||||||
|
puts
|
||||||
|
puts "USAGE: feature merge [branch]"
|
||||||
|
puts
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
parts = parse_branch(current_branch)
|
parts = parse_branch(current_branch)
|
||||||
|
|
||||||
@@ -10,8 +21,6 @@ module Feature
|
|||||||
merge_to_branch = argv[1]
|
merge_to_branch = argv[1]
|
||||||
elsif argv.size == 1
|
elsif argv.size == 1
|
||||||
merge_to_branch = parts[:standard]
|
merge_to_branch = parts[:standard]
|
||||||
else
|
|
||||||
error "USAGE: feature merge [branch]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature_branch = current_branch
|
feature_branch = current_branch
|
||||||
|
|||||||
@@ -3,6 +3,18 @@ require_relative './base'
|
|||||||
module Feature
|
module Feature
|
||||||
|
|
||||||
class Rebase < Feature::Base
|
class Rebase < Feature::Base
|
||||||
|
|
||||||
|
def valid?
|
||||||
|
argv.size == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def help
|
||||||
|
puts
|
||||||
|
puts "USAGE: feature rebase"
|
||||||
|
puts
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
parts = parse_branch(current_branch)
|
parts = parse_branch(current_branch)
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,18 @@ require_relative './base'
|
|||||||
module Feature
|
module Feature
|
||||||
|
|
||||||
class Start < Feature::Base
|
class Start < Feature::Base
|
||||||
def execute
|
def valid?
|
||||||
error "USAGE: feature start feature_name" unless argv.size == 2
|
argv.size == 2
|
||||||
|
end
|
||||||
|
|
||||||
|
def help
|
||||||
|
puts
|
||||||
|
puts "USAGE: feature start feature_name"
|
||||||
|
puts
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
feature = argv[1]
|
feature = argv[1]
|
||||||
feature_branch = "#{ENV['USER']}-#{current_branch}-#{feature}"
|
feature_branch = "#{ENV['USER']}-#{current_branch}-#{feature}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user