From 986559fba7c7d854bb0b5396819801b3bef0c573 Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Sun, 4 Oct 2009 20:00:32 -0400 Subject: [PATCH] freeze: use optparse to parse arguments --- bin/cython_freeze | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/cython_freeze b/bin/cython_freeze index 93b1e589..b2816304 100755 --- a/bin/cython_freeze +++ b/bin/cython_freeze @@ -6,11 +6,17 @@ Requires Cython 0.11.2 (or perhaps newer). See Demos/freeze/README.rst for more details. """ -import sys +import optparse -if len(sys.argv) < 2: - print >>sys.stderr, "USAGE: %s module [module ...]" % sys.argv[0] - sys.exit(1) +usage= '%prog module [module ...]' +description = 'Create a C file for embedding Cython modules.' +p = optparse.OptionParser(usage=usage, description=description) + +options, args = p.parse_args() + +if len(args) < 1: + p.print_help() + p.exit(1) def format_modname(name): if name.endswith('.pyx'): @@ -19,7 +25,7 @@ def format_modname(name): name = name[:-3] return name.replace('.','_') -modules = [format_modname(x) for x in sys.argv[1:]] +modules = [format_modname(x) for x in args] print """ #include -- 2.26.2