Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
go_manage_routing_table: separate COMMAND_ and LOCAL_OPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
JayH5 committed Jun 22, 2015
1 parent 419acae commit 73676c3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions go/base/management/commands/go_manage_routing_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Command(BaseGoAccountCommand):
help = "Manage the routing table for a Vumi Go user"

LOCAL_OPTIONS = [
COMMAND_OPTIONS = [
make_option('--show',
dest='show',
action='store_true',
Expand All @@ -31,7 +31,11 @@ class Command(BaseGoAccountCommand):
help='Remove the routing table entry with four params: '
'src_conn src_endpoint dest_conn dest_endpoint'),
]
option_list = BaseGoAccountCommand.option_list + tuple(LOCAL_OPTIONS)
LOCAL_OPTIONS = []
option_list = (
BaseGoAccountCommand.option_list +
tuple(COMMAND_OPTIONS) +
tuple(LOCAL_OPTIONS))

def handle_no_command(self, *args, **options):
options = options.copy()
Expand All @@ -43,11 +47,11 @@ def handle_no_command(self, *args, **options):
else:
raise CommandError('Please provide %s:' % (opt.dest,))

# Ensure a single option is chosen from the local options
cmd_options = [c.dest for c in self.LOCAL_OPTIONS if options[c.dest]]
# Ensure a single option is chosen from the command options
cmd_options = [c.dest for c in self.COMMAND_OPTIONS if options[c.dest]]
if len(cmd_options) != 1:
raise CommandError('Please provide exactly one of: %s' % (
['--%s' % c.dest for c in self.LOCAL_OPTIONS],))
['--%s' % c.dest for c in self.COMMAND_OPTIONS],))

if options['show']:
return self.handle_show(options)
Expand Down

0 comments on commit 73676c3

Please sign in to comment.