Hi Andrew, could you please share the contents of the install function?
I tried your code in the following way and it works for me, i.e. the
function is called once and prints install 1.2.3
***
import argparse
def stop(args):
print 'stop'
def start(args):
print 'start'
def install(args):
print 'install %s' % args.version
if __name__ == '__main__':
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
start_parser = subparsers.add_parser('start')
start_parser.set_defaults(func=start)
stop_parser = subparsers.add_parser('stop')
stop_parser.set_defaults(func=stop)
install_parser = subparsers.add_parser('install')
install_parser.set_defaults(func=install)
install_parser.add_argument('version')
parsed_args = parser.parse_args()
parsed_args.func(parsed_args)
--
Giovanni Luca Ciampaglia
Ph.D. Candidate
Faculty of Informatics
University of Lugano
Web: http://www.inf.usi.ch/phd/ciampaglia/
Bertastraße 36 ∙ 8003 Zürich ∙ Switzerland
Mobile: +41 79 718 8157