argument_parser_test.py 1.57 KB
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys 
import os
import os.path as op
import json
import argparse
	
		
def main():
	parser = argparse.ArgumentParser()

	parser.add_argument('-l', action='store', dest='location',
						help='Location')

	parser.add_argument('-d', action='store', dest='current_date',
						help='The desired date to process')

	parser.add_argument('-c', action='store', dest='clear_date',
						help='The nearest clear date')


	results = parser.parse_args()
	print('Location : {}'.format(results.location))
	print('Current date : {}'.format(results.current_date))
	print('Clear date : {}'.format(results.clear_date))


	#~ parser.add_argument('-a', action='append', dest='collection',
						#~ default=[],
						#~ help='Add repeated values to a list',
						#~ )

	#~ parser.add_argument('-c', action='store_const', dest='constant_value',
						#~ const='value-to-store',
						#~ help='Store a constant value')

	#~ parser.add_argument('-t', action='store_true', default=False,
						#~ dest='boolean_switch',
						#~ help='Set a switch to true')
	#~ parser.add_argument('-f', action='store_false', default=False,
						#~ dest='boolean_switch',
						#~ help='Set a switch to false')



	#~ parser.add_argument('-A', action='append_const', dest='const_collection',
						#~ const='value-1-to-append',
						#~ default=[],
						#~ help='Add different values to list')
	#~ parser.add_argument('-B', action='append_const', dest='const_collection',
						#~ const='value-2-to-append',
						#~ help='Add different values to list')



if __name__ == '__main__':
	main()