equal
deleted
inserted
replaced
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """some utilities for cubicweb tools |
18 """some utilities for cubicweb command line tools""" |
19 |
19 |
20 """ |
|
21 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
22 |
21 |
23 # XXX move most of this in logilab.common (shellutils ?) |
22 # XXX move most of this in logilab.common (shellutils ?) |
24 |
23 |
25 import os, sys |
24 import os, sys |
31 from os import symlink |
30 from os import symlink |
32 except ImportError: |
31 except ImportError: |
33 def symlink(*args): |
32 def symlink(*args): |
34 raise NotImplementedError |
33 raise NotImplementedError |
35 |
34 |
36 from logilab.common.clcommands import Command as BaseCommand, \ |
35 from logilab.common.clcommands import Command as BaseCommand |
37 main_run as base_main_run |
|
38 from logilab.common.compat import any |
36 from logilab.common.compat import any |
39 from logilab.common.shellutils import ASK |
37 from logilab.common.shellutils import ASK |
40 |
38 |
41 from cubicweb import warning |
39 from cubicweb import warning |
42 from cubicweb import ConfigurationError, ExecutionError |
40 from cubicweb import ConfigurationError, ExecutionError |
258 def fail(self, reason): |
256 def fail(self, reason): |
259 print "command failed:", reason |
257 print "command failed:", reason |
260 sys.exit(1) |
258 sys.exit(1) |
261 |
259 |
262 |
260 |
263 def main_run(args, doc): |
|
264 """command line tool""" |
|
265 try: |
|
266 base_main_run(args, doc, copyright=None) |
|
267 except ConfigurationError, err: |
|
268 print 'ERROR: ', err |
|
269 sys.exit(1) |
|
270 except ExecutionError, err: |
|
271 print err |
|
272 sys.exit(2) |
|
273 |
|
274 CONNECT_OPTIONS = ( |
261 CONNECT_OPTIONS = ( |
275 ("user", |
262 ("user", |
276 {'short': 'u', 'type' : 'string', 'metavar': '<user>', |
263 {'short': 'u', 'type' : 'string', 'metavar': '<user>', |
277 'help': 'connect as <user> instead of being prompted to give it.', |
264 'help': 'connect as <user> instead of being prompted to give it.', |
278 } |
265 } |