From 94560c3fab6c86ca50b7f9877ed07d06806a7c8c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 10 Dec 2005 02:07:15 +0000 Subject: touchup in general, add support for -h/--help, and delay importing portage so using -h/--help doesnt blow goats because portage was imported svn path=/main/trunk/; revision=2356 --- bin/portageq | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'bin') diff --git a/bin/portageq b/bin/portageq index 9b1d682fc..f93ba7dea 100755 --- a/bin/portageq +++ b/bin/portageq @@ -7,7 +7,7 @@ import sys, os os.environ["PORTAGE_CALLER"] = "portageq" sys.path = ["/usr/lib/portage/pym"]+sys.path -import portage,types,string +import types,string #----------------------------------------------------------------------------- @@ -149,52 +149,53 @@ def gentoo_mirrors(argv): def portdir(argv): """ - Returns the PORTDIR path as defined in the portage configuration. + Returns the PORTDIR path. """ print portage.settings["PORTDIR"] def config_protect(argv): """ - Returns the CONFIG_PROTECT paths as defined in the portage configuration. + Returns the CONFIG_PROTECT paths. """ print portage.settings["CONFIG_PROTECT"] def config_protect_mask(argv): """ - Returns the CONFIG_PROTECT_MASK paths as defined in the portage configuration. + Returns the CONFIG_PROTECT_MASK paths. """ print portage.settings["CONFIG_PROTECT_MASK"] def portdir_overlay(argv): """ - Returns the PORTDIR_OVERLAY path as defined in the portage configuration. + Returns the PORTDIR_OVERLAY path. """ print portage.settings["PORTDIR_OVERLAY"] def pkgdir(argv): """ - Returns the PKGDIR path as defined in the portage configuration. + Returns the PKGDIR path. """ print portage.settings["PKGDIR"] def distdir(argv): """ - Returns the DISTDIR path as defined in the portage configuration. + Returns the DISTDIR path. """ print portage.settings["DISTDIR"] def envvar(argv): - """ + """+ Returns a specific environment variable as exists prior to ebuild.sh. Similar to: emerge --verbose --info | egrep '^=' """ - print portage.settings[argv[0]] + for arg in argv: + print portage.settings[arg] #----------------------------------------------------------------------------- @@ -233,24 +234,31 @@ def usage(argv): lines = string.split(doc, '\n') print " "+name+" "+string.strip(lines[0]) - for line in lines[1:]: - print " "+string.strip(line) - + if (len(sys.argv) > 1): + if ("--help" not in sys.argv): + lines = lines[:-1] + for line in lines[1:]: + print " "+string.strip(line) + if (len(sys.argv) == 1): + print "\nRun portageq with --help for info" def main(): - if (len(sys.argv) < 2): + if (len(sys.argv) < 2) or ("-h" in sys.argv or "--help" in sys.argv): usage(sys.argv) sys.exit() - + + # no more fatties + global portage + import portage + cmd = sys.argv[1] try: function = globals()[cmd] function(sys.argv[2:]) except KeyError: - usage() + usage(sys.argv) sys.exit() main() - #----------------------------------------------------------------------------- -- cgit v1.2.3-1-g7c22