diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-12-10 02:07:15 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-12-10 02:07:15 +0000 |
commit | 94560c3fab6c86ca50b7f9877ed07d06806a7c8c (patch) | |
tree | c29c8f0d5b121806ec3ce02c72e95f8b0325e239 | |
parent | ea6e2ea0b985399d2b9ee729400e348ac9dda7d1 (diff) | |
download | portage-94560c3fab6c86ca50b7f9877ed07d06806a7c8c.tar.gz portage-94560c3fab6c86ca50b7f9877ed07d06806a7c8c.tar.bz2 portage-94560c3fab6c86ca50b7f9877ed07d06806a7c8c.zip |
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
-rwxr-xr-x | bin/portageq | 40 |
1 files changed, 24 insertions, 16 deletions
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): - """<variable> + """<variable>+ Returns a specific environment variable as exists prior to ebuild.sh. Similar to: emerge --verbose --info | egrep '^<variable>=' """ - 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() - #----------------------------------------------------------------------------- |