Skip to content
Permalink
Browse files

Add the "prompt_emptyline_repeat_cmd" config option

Changes the default of repeating the last command on an empty line to
false, while still keeping it as a configurable option.
  • Loading branch information...
liviuchircu committed Apr 11, 2019
1 parent f49ec4f commit f29863e204ba0a8f9bdb205d3be18f849f2c108c
Showing with 16 additions and 10 deletions.
  1. +9 −9 README.md
  2. +1 −0 etc/default.cfg
  3. +4 −0 opensipscli/cli.py
  4. +2 −1 opensipscli/defaults.py
@@ -70,17 +70,17 @@ CLI searches for one in the following locations, in this exact order:

The OpenSIPS CLI core can use the following parameters:

* `prompt_name`: The name of the OpenSIPS CLI prompt (Defaults to `opensips-cli`)
* `prompt_name`: The name of the OpenSIPS CLI prompt (Default: `opensips-cli`)
* `prompt_intro`: Introduction message when entering the OpenSIPS CLI
* `history_file`: The path of the history file (Defaults to `~/.opensips-cli.history`)
* `history_file_size`: The backlog size of the history file (Defaults to
`1000`)
* `log_level`: The level of the console logging (Defaults to `WARNING`)
* `communication_type`: Communication transport used by OpenSIPS CLI (Defaults
to `fifo`)
* `fifo_file`: The file OpenSIPS uses to communicate with OpenSIPS through
* `prompt_emptyline_repeat_cmd`: Repeat the last command on an emptyline (Default: `False`)
* `history_file`: The path of the history file (Default: `~/.opensips-cli.history`)
* `history_file_size`: The backlog size of the history file (Default: `1000`)
* `log_level`: The level of the console logging (Default: `WARNING`)
* `communication_type`: Communication transport used by OpenSIPS CLI (Default: `fifo`)
* `fifo_file`: The OpenSIPS FIFO file to which the CLI will write commands
(Default: `/tmp/opensips_fifo`)
* `url`: The default URL used when `http` `communication_type` is used
(Defaults to `http://127.0.0.1:8888/json`).
(Default: `http://127.0.0.1:8888/json`).

Each module can use each of the parameters above, but can also declare their
own. You can find in each module's documentation page the parameters that they
@@ -2,6 +2,7 @@
log_level: WARNING
prompt_name: opensips-cli
prompt_intro: Welcome to OpenSIPS Command Line Interface!
prompt_emptyline_repeat_cmd: False
history_file: ~/.opensips-cli.history
history_file_size: 1000
output_type: pretty-print
@@ -207,6 +207,10 @@ def cmdloop(self, intro=None):
# any other commands exits with negative value
return -1

def emptyline(self):
if cfg.getBool('prompt_emptyline_repeat_cmd'):
super().emptyline()

def complete_modules(self, text):
l = [a for a in self.modules.keys() if a.startswith(text)]
if len(l) == 1:
@@ -50,6 +50,7 @@
# CLI settings
"prompt_name": "opensips-cli",
"prompt_intro": "Welcome to OpenSIPS Command Line Interface!",
"prompt_emptyline_repeat_cmd": "False",
"history_file": HISTORY_FILE,
"history_file_size": "1000",
"output_type": "pretty-print",
@@ -66,7 +67,7 @@
"database_password": "opensipsrw",

# user module
"plain_text_passwords": False,
"plain_text_passwords": "False",
}

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

0 comments on commit f29863e

Please sign in to comment.
You can’t perform that action at this time.