The argument was not called when I used "kindledx" after the "-k" flag?
That was, and if you add print args
after args = parser.parse_args()
, you will see that the parsing works:
~/coding$ python ap.py -k kindledx http://url.com Namespace(dropbox_dir=None, gallery_name='Gallery', kindle_type='kindledx', url='http://url.com')
but on this line
print parser.parse_args(['imgur_url', '-k'])
you are not passing argument k. Compare
print parser.parse_args(['imgur_url', '-k', 'kindledx'])
which produces
Namespace(dropbox_dir=None, gallery_name='Gallery', kindle_type='kindledx', url='imgur_url')
source share