From 54df6c66ccebfa238126bad543b1af08524cedc6 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 8 Oct 2013 15:58:58 -0400 Subject: [PATCH] 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. --- bin/chpathtool.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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() -- 2.26.2