diff options
author | Yann E. MORIN <yann.morin.1998@free.fr> | 2014-04-13 22:42:38 +0200 |
---|---|---|
committer | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2014-04-14 20:56:18 +0200 |
commit | 3d37950ec171944aacf3e6fd4ec2a349181db617 (patch) | |
tree | 2926bf08db7e61b7085529c6a2e4b722999b08ee /support/scripts/graph-depends | |
parent | 22d05901c37820fe9fcfa606ab09e2c7325b2d31 (diff) | |
download | buildroot-3d37950ec171944aacf3e6fd4ec2a349181db617.tar.gz buildroot-3d37950ec171944aacf3e6fd4ec2a349181db617.zip |
support/graph-depends: use argparse to parse argv[]
Currently, we are using a crude, ad-hoc parsing of argv[].
This is a limiting factor to adding new options.
Use argparse instead, and introduce a single argument for now:
--package, -p PACKAGE
In the (near) future, we'll be able to add more option arguments,
such as depth-limiting for big graphs.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support/scripts/graph-depends')
-rwxr-xr-x | support/scripts/graph-depends | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends index ac240867bc..fc3cadde87 100755 --- a/support/scripts/graph-depends +++ b/support/scripts/graph-depends @@ -1,13 +1,13 @@ #!/usr/bin/python # Usage (the graphviz package must be installed in your distribution) -# ./support/scripts/graph-depends [package-name] > test.dot +# ./support/scripts/graph-depends [-p package-name] > test.dot # dot -Tpdf test.dot -o test.pdf # # With no arguments, graph-depends will draw a complete graph of -# dependencies for the current configuration. With an argument, -# graph-depends will draw a graph of dependencies for the given -# package name. +# dependencies for the current configuration. +# If '-p <package-name>' is specified, graph-depends will draw a graph +# of dependencies for the given package name. # # Limitations # @@ -21,6 +21,7 @@ import sys import subprocess +import argparse # In FULL_MODE, we draw the full dependency graph for all selected # packages @@ -31,14 +32,16 @@ PKG_MODE = 2 mode = 0 -if len(sys.argv) == 1: +parser = argparse.ArgumentParser(description="Graph pacakges dependencies") +parser.add_argument("--package", '-p', metavar="PACKAGE", + help="Graph the dependencies of PACKAGE") +args = parser.parse_args() + +if args.package == None: mode = FULL_MODE -elif len(sys.argv) == 2: - mode = PKG_MODE - rootpkg = sys.argv[1] else: - print "Usage: graph-depends [package-name]" - sys.exit(1) + mode = PKG_MODE + rootpkg = args.package allpkgs = [] |