Commit 30f8306d authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add arguments for changing output separator

Two new arguments added to main():
  --zero -z: Use a null as separator
  --sep -s:  Set an explicit separator

The default separator is a carriage return.
parent e9e962d6
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
__version__ = '0.1'


import sys


def main():
	import sys
	import argparse
	from . import walk
	argp = argparse.ArgumentParser()
	argp.add_argument('--zero', '-z',
		action='store_const', dest='sep', default='\n', const='\0',
		help="""
		Print file names separated by null characters. Useful for passing the
		output for further processing when file names could contain whitespace
		characters or special processing characters.
		""")
	argp.add_argument('--sep', '-s',
		help="""
		Use SEP to separate file names. (default is a carriage return)
		""")
	argp.add_argument('start_dir',
		default='.', nargs='?',
		help="""
@@ -13,8 +27,12 @@ def main():
		""")

	options = argp.parse_args()
	write = sys.stdout.write
	sep = options.sep

	for f in walk.walk_files(options.start_dir):
		print(f)
		write(f)
		write(sep)


def mainwrap():