diff --git a/bin/commit b/bin/commit index 29afedd..e896f28 100755 --- a/bin/commit +++ b/bin/commit @@ -1,9 +1,10 @@ #!/usr/bin/env ruby -raise "USAGE: commit [word....]" unless ARGV.size > 0 +require_relative '../lib/commit/commander' -comment = ARGV.reject { |x| x == '-m' }.join(' ') - -command = "git commit -m \"#{comment}\"" - -exec command +commander = Commit::Commander.new(ARGV) +if commander.valid? + commander.execute +else + commander.help +end diff --git a/lib/commit/commander.rb b/lib/commit/commander.rb new file mode 100644 index 0000000..966af16 --- /dev/null +++ b/lib/commit/commander.rb @@ -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 diff --git a/lib/feature/end.rb b/lib/feature/end.rb index a090d97..f4199bf 100644 --- a/lib/feature/end.rb +++ b/lib/feature/end.rb @@ -4,7 +4,7 @@ module Feature class End < Feature::Base def execute - error "USAGE: feature end" unless ARGV.size == 1 + error "USAGE: feature end" unless argv.size == 1 parts = parse_branch(current_branch)