breakout commit

This commit is contained in:
rkiel
2015-06-06 07:16:32 -04:00
parent a68a450006
commit db0a6f5501
3 changed files with 38 additions and 7 deletions

View File

@@ -1,9 +1,10 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
raise "USAGE: commit [word....]" unless ARGV.size > 0 require_relative '../lib/commit/commander'
comment = ARGV.reject { |x| x == '-m' }.join(' ') commander = Commit::Commander.new(ARGV)
if commander.valid?
command = "git commit -m \"#{comment}\"" commander.execute
else
exec command commander.help
end

30
lib/commit/commander.rb Normal file
View File

@@ -0,0 +1,30 @@
module Commit
class Commander
attr_reader :argv
def initialize (argv)
@argv = argv
end
def valid?
argv.size > 0
end
def help
puts
puts "USAGE: commit [word....]"
puts
exit
end
def execute
comment = argv.reject { |x| x == '-m' }.join(' ')
command = "git commit -m \"#{comment}\""
exec command
end
end
end

View File

@@ -4,7 +4,7 @@ module Feature
class End < Feature::Base class End < Feature::Base
def execute def execute
error "USAGE: feature end" unless ARGV.size == 1 error "USAGE: feature end" unless argv.size == 1
parts = parse_branch(current_branch) parts = parse_branch(current_branch)