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
     pass
9
     pass
10
 
10
 
11
 
11
 
12
+class SardinePluginUsageError(SardinePluginError):
13
+    pass
14
+
15
+
12
 class XGPRenderer(object):
16
 class XGPRenderer(object):
13
 
17
 
14
     def __init__(self, txt=None):
18
     def __init__(self, txt=None):
98
 
102
 
99
 class App:
103
 class App:
100
 
104
 
105
+    name = "sardine"
106
+
101
     def __init__(self, cmdargs):
107
     def __init__(self, cmdargs):
102
         self.cmdargs = cmdargs
108
         self.cmdargs = cmdargs
103
         self._set_pluginpath()
109
         self._set_pluginpath()
119
         try:
125
         try:
120
             self.subcommand = Subcommand(self.cmdargs, self.pluginpath)
126
             self.subcommand = Subcommand(self.cmdargs, self.pluginpath)
121
             print self.subcommand.get_output()
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
         except SardinePluginError as e:
132
         except SardinePluginError as e:
123
             self.die(e, 10)
133
             self.die(e, 10)