#!/usr/bin/env ruby

require 'git_ui'
include GitUI

args = ARGV.dup

if args.empty? || %w(-h --help -help help).any?(&args.method(:include?))
	puts "Available commands:",
		"add:  Add files to the repository",
		"record:  Record changes (stages and commits) interactively"
	exit 0
end

cmd = determine_cmd args

if cmd.nil?
	$stderr.puts "Command doesn't make sense:  #{args}"
	exit 1
end

# git usually gives paths relative to the repo's root, but sometimes requires
# paths relative to the working directory.
dotgit = GitUI.find_dotgit
if File.expand_path('.') != dotgit
	puts "Looks like the root of this repo is #{dotgit}..."
	Dir.chdir dotgit
end

cmd[]
