equal
deleted
inserted
replaced
12 |
12 |
13 from VirtualMailManager import ENCODING, errors |
13 from VirtualMailManager import ENCODING, errors |
14 from VirtualMailManager.config import BadOptionError, ConfigValueError |
14 from VirtualMailManager.config import BadOptionError, ConfigValueError |
15 from VirtualMailManager.cli import w_err |
15 from VirtualMailManager.cli import w_err |
16 from VirtualMailManager.cli.handler import CliHandler |
16 from VirtualMailManager.cli.handler import CliHandler |
17 from VirtualMailManager.constants import EX_SUCCESS, EX_USER_INTERRUPT, \ |
17 from VirtualMailManager.constants import EX_MISSING_ARGS, EX_SUCCESS, \ |
18 INVALID_ARGUMENT |
18 EX_USER_INTERRUPT, INVALID_ARGUMENT |
19 from VirtualMailManager.cli.subcommands import RunContext, setup_parser |
19 from VirtualMailManager.cli.subcommands import RunContext, setup_parser |
20 |
20 |
21 |
21 |
22 _ = lambda msg: msg |
22 _ = lambda msg: msg |
23 |
23 |
32 else: |
32 else: |
33 handler.cfg_install() |
33 handler.cfg_install() |
34 return handler |
34 return handler |
35 |
35 |
36 |
36 |
37 def run(): |
37 def run(argv): |
38 parser = setup_parser() |
38 parser = setup_parser() |
|
39 if len(argv) < 2: |
|
40 parser.print_usage() |
|
41 parser.exit(status=EX_MISSING_ARGS, |
|
42 message=_('You must specify a subcommand at least.') + '\n') |
39 args = parser.parse_args() |
43 args = parser.parse_args() |
40 handler = _get_handler() |
44 handler = _get_handler() |
41 run_ctx = RunContext(args, handler) |
45 run_ctx = RunContext(args, handler) |
42 try: |
46 try: |
43 args.func(run_ctx) |
47 args.func(run_ctx) |