From 49a30d0c43890069085d809903daeb57d9da9dae Mon Sep 17 00:00:00 2001 From: j Date: Thu, 15 Jun 2017 08:57:53 +0200 Subject: [PATCH] use argparse --- bin/pandora_client | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/pandora_client b/bin/pandora_client index d6ed302..0d5d9f3 100755 --- a/bin/pandora_client +++ b/bin/pandora_client @@ -6,7 +6,8 @@ from __future__ import print_function import os import sys -from optparse import OptionParser +from argparse import ArgumentParser + import json @@ -18,14 +19,16 @@ if os.path.exists(os.path.join(root, 'pandora_client')): import pandora_client if __name__ == '__main__': - usage = "usage: %prog [options] action" - parser = OptionParser(usage=usage) - parser.add_option('-v', '--version', dest='version', action="store_true") - parser.add_option('-c', '--config', dest='config', - help='config.json containing config', default='~/.ox/client.json', type='string') - parser.add_option('-d', '--debug', dest='debug', + usage = "usage: %(prog)s [options] action" + parser = ArgumentParser(usage=usage) + parser.add_argument('-v', '--version', dest='version', action="store_true") + parser.add_argument('-c', '--config', dest='config', + help='config.json containing config', default='~/.ox/client.json') + parser.add_argument('-d', '--debug', dest='debug', help='output debug information', action="store_true") - (opts, args) = parser.parse_args() + parser.add_argument('files', metavar='path', type=str, nargs='*', help='files or hashes') + opts = parser.parse_args() + args = opts.files if opts.version: print("%s %s" % (os.path.basename(sys.argv[0]), pandora_client.__version__))