Browse Source

Add error condition for plugin usage message

Alois Mahdal 10 years ago
parent
commit
be867461ab
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      include/sardine.py

+ 10
- 0
include/sardine.py View File

@@ -9,6 +9,10 @@ class SardinePluginError(Exception):
9 9
     pass
10 10
 
11 11
 
12
+class SardinePluginUsageError(SardinePluginError):
13
+    pass
14
+
15
+
12 16
 class XGPRenderer(object):
13 17
 
14 18
     def __init__(self, txt=None):
@@ -98,6 +102,8 @@ class Subcommand(object):
98 102
 
99 103
 class App:
100 104
 
105
+    name = "sardine"
106
+
101 107
     def __init__(self, cmdargs):
102 108
         self.cmdargs = cmdargs
103 109
         self._set_pluginpath()
@@ -119,5 +125,9 @@ class App:
119 125
         try:
120 126
             self.subcommand = Subcommand(self.cmdargs, self.pluginpath)
121 127
             print self.subcommand.get_output()
128
+        except SardinePluginUsageError as e:
129
+            msg = ("plugin usage: %s %s %s"
130
+                   % (self.name, self.subcommand.name, e))
131
+            self.die(msg, 11)
122 132
         except SardinePluginError as e:
123 133
             self.die(e, 10)