Skip to content

Commit

Permalink
database: Fix broken 'database' command
Browse files Browse the repository at this point in the history
* Fix the 'database' command, so it once again displays the possible
arguments.

* Re-order the 'database' arguments in a logical order (who cares about
alphabet sorting if all arguments are mixed up, maybe most relevant ones
last?)

Reported by @vma
  • Loading branch information
liviuchircu committed Jun 16, 2019
1 parent ed8cc10 commit cfe24b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion opensipscli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def run_command(self, module, cmd, params):
logger.error("no command '{}' in module '{}'".
format(cmd, module))
return -1
logger.debug("running command '%s' with %i arguments: %s'", cmd, len(params), params)
logger.debug("running command '{}' '{}'".format(cmd, params))
return mod[0].__invoke__(cmd, params)

def default(self, line):
Expand Down
31 changes: 12 additions & 19 deletions opensipscli/modules/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,18 @@ def __get_methods__(self):
"""
methods available for autocompletion
"""
return ['', 'add', 'alter_role',
'create', 'create_db', 'create_module', 'create_role',
'drop', 'drop_role', 'get_role', 'migrate']
return [
'create',
'drop',
'add',
'migrate',
'create_role',
'alter_role',
'drop_role',
'get_role',
'create_db',
'create_module',
]

def ask_db_url(self):
db_url = cfg.read_param("template_url",
Expand All @@ -226,22 +235,6 @@ def ask_db_url(self):

return db_url

#def __invoke__(self, cmd, params=None):
# """
# methods handles to preset defaults
# """
# if cmd is None:
# return self.diagnosis_summary()
# if cmd == 'create_role':
# #if not params:
# #params = ['role_name', 'role_options']
# #params = ['opensips', 'NOCREATEDB NOCREATEROLE LOGIN REPLICATION']
# return self.do_create_role(params)
# if cmd == 'drop_role':
# return self.do_drop_role(params)
# if cmd == 'get_role':
# return self.do_get_role()

def do_add(self, params):
"""
add a given table to the database (connection via URL)
Expand Down

0 comments on commit cfe24b9

Please sign in to comment.