I like consistency, you like consistency, we like consistency
This commit is contained in:
+10
-7
@@ -23,9 +23,11 @@ from pisi.cli import printu
|
|||||||
from pisi.uri import URI
|
from pisi.uri import URI
|
||||||
from pisi.cli.commands import *
|
from pisi.cli.commands import *
|
||||||
|
|
||||||
class ParserError(Exception):
|
class ParserError(pisi.Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class Error(pisi.Error):
|
||||||
|
pass
|
||||||
|
|
||||||
class PreParser(OptionParser):
|
class PreParser(OptionParser):
|
||||||
"""consumes any options, and finds arguments from command line"""
|
"""consumes any options, and finds arguments from command line"""
|
||||||
@@ -87,19 +89,20 @@ class PisiCLI(object):
|
|||||||
if 'version' in opts:
|
if 'version' in opts:
|
||||||
self.parser.print_version()
|
self.parser.print_version()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
printu(_('No command given'))
|
raise Error(_('No command given'))
|
||||||
self.die()
|
#self.die()
|
||||||
cmd_name = args[0]
|
cmd_name = args[0]
|
||||||
except ParserError:
|
except ParserError:
|
||||||
printu(_('Command line parsing error'))
|
raise Error(_('Command line parsing error'))
|
||||||
self.die()
|
#self.die()
|
||||||
|
|
||||||
self.command = Command.get_command(cmd_name)
|
self.command = Command.get_command(cmd_name)
|
||||||
if not self.command:
|
if not self.command:
|
||||||
printu(_("Unrecognized command: %s") % cmd_name)
|
raise Error(_("Unrecognized command: %s") % cmd_name)
|
||||||
self.die()
|
#self.die()
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
|
#raise Error('')
|
||||||
printu('\n' + self.parser.format_help())
|
printu('\n' + self.parser.format_help())
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user