From: Mike Frysinger Date: Tue, 8 Oct 2013 19:58:58 +0000 (-0400) Subject: chpathtool: clean up arg parsing to use proper argparse module X-Git-Tag: v2.2.8~64 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=54df6c66ccebfa238126bad543b1af08524cedc6;p=portage.git chpathtool: clean up arg parsing to use proper argparse module Also throw in some documentation for good measure since not everyone knows what this thing does. --- diff --git a/bin/chpathtool.py b/bin/chpathtool.py index b8c6fd5cb..aa3b7d478 100755 --- a/bin/chpathtool.py +++ b/bin/chpathtool.py @@ -2,6 +2,10 @@ # Copyright 2011-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +"""Helper tool for converting installed files to custom prefixes. + +In other words, eprefixy $D for Gentoo/Prefix.""" + import io import os import stat @@ -142,14 +146,16 @@ def chpath_inplace_symlink(filename, st, old, new): def main(argv): - usage = '%(prog)s [options] ' - parser = ArgumentParser(usage=usage) - options, args = parser.parse_known_args(argv) - - if len(args) != 3: - parser.error('3 args required, got %s' % (len(args),)) + parser = ArgumentParser(description=__doc__) + parser.add_argument('location', default=None, + help='root directory (e.g. $D)') + parser.add_argument('old', default=None, + help='original build prefix (e.g. /)') + parser.add_argument('new', default=None, + help='new install prefix (e.g. $EPREFIX)') + opts = parser.parse_args(argv) - location, old, new = args + location, old, new = opts.location, opts.old, opts.new is_text_file = IsTextFile()