#!/usr/bin/env python

import os
import argparse

import ignor

IGNORE_FILE = ".git/info/exclude"

def main():
	parser = argparse.ArgumentParser()
	parser.add_argument("file")
	args = parser.parse_args()

	git_repo_base = ignor.find_git_repo_base(os.getcwd())

	# Get path of target file w.r.t to git repo base
	target_file_abs = os.path.abspath(args.file)
	if os.path.isdir(target_file):
		target_file += "/"
	target_file = target_file_abs[len(git_repo_base):]

	# Get abs path of ignore file
	ignore_file = git_repo_base + "/" + IGNORE_FILE

	ignor.ignore(target_file, ignore_file)

	print("Added line: " + target_file)
	print("To ignore file: " + ignore_file)

if __name__ == '__main__':
	main()