summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xportato.py81
1 files changed, 41 insertions, 40 deletions
diff --git a/portato.py b/portato.py
index 08d7123..e4210bb 100755
--- a/portato.py
+++ b/portato.py
@@ -13,54 +13,55 @@
# Written by René 'Necoro' Neumann <necoro@necoro.net>
from portato.constants import VERSION, FRONTENDS, STD_FRONTEND
+from optparse import OptionParser
import sys
+def get_frontend_list ():
+ return ", ".join(["'%s'" % x for x in FRONTENDS])
+
def main ():
- uimod = STD_FRONTEND
- do_ebuild = False
- ebuild_pkg = None
- for arg in sys.argv[1:]:
- if arg in ("--help","--version","-h","-v"):
- print """Portato %s
-Copyright (C) 2006-2007 René 'Necoro' Neumann
-This is free software. You may redistribute copies of it under the terms of
-the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
-There is NO WARRANTY, to the extent permitted by law.
+ # build the parser
+ desc = """Portato - A Portage GUI."""
+ usage = "%prog [options] [frontend]"
+ vers = "%%prog v. %s" % VERSION
+
+ parser = OptionParser(version = vers, prog = "Portato", description = desc, usage = usage)
+
+ parser.add_option("--check", action = "store_true", dest = "check", default = False,
+ help = "runs pychecker (should only be used by developers)")
+
+ parser.add_option("-f", "--frontend", action = "store", choices = FRONTENDS, default = STD_FRONTEND, dest = "frontend",
+ help = "the frontend to use - possible values are: %s [default: %%default]" % get_frontend_list())
+
+ parser.add_option("-e", "--ebuild", action = "store", dest = "ebuild",
+ help = "opens the ebuild viewer instead of launching Portato")
-Written by René 'Necoro' Neumann <necoro@necoro.net>""" % VERSION
- sys.exit(0)
-
- elif arg == "--check": # run pychecker
- import os
- os.environ['PYCHECKER'] = "--limit 50"
- import pychecker.checker
-
- elif arg in ("--ebuild", "-e"):
- do_ebuild = True
-
- elif do_ebuild:
- ebuild_pkg = arg
- do_ebuild = False
-
+ # run parser
+ (options, args) = parser.parse_args()
+
+ # evaluate parser's results
+ if options.check: # run pychecker
+ import os
+ os.environ['PYCHECKER'] = "--limit 50"
+ import pychecker.checker
+
+ if len(args): # additional arguments overwrite given frontend
+ arg = args[0]
+ if arg not in FRONTENDS:
+ print "Unknown frontend '%s'. Correct frontends are: %s" % (arg, get_frontend_list())
+ sys.exit(2)
else:
- uimod = arg
+ options.frontend = arg
- if uimod in FRONTENDS:
- try:
- exec ("from portato.gui.%s import run, show_ebuild" % uimod)
- except ImportError, e:
- print "'%s' should be installed, but cannot be imported. This is definitly a bug. (%s)" % (uimod, e[0])
- sys.exit(1)
- else:
- print ("Unknown interface '%s'. Correct interfaces are:" % uimod) ,
- for u in FRONTENDS:
- print u ,
- print
+ try:
+ exec ("from portato.gui.%s import run, show_ebuild" % options.frontend)
+ except ImportError, e:
+ print "'%s' should be installed, but cannot be imported. This is definitly a bug. (%s)" % (options.frontend, e[0])
sys.exit(1)
-
- if ebuild_pkg:
- show_ebuild(ebuild_pkg)
+
+ if options.ebuild:
+ show_ebuild(options.ebuild)
else:
run()
td>Necoro9-394/+477 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108