Skip to content

Commit

Permalink
Merge branch 'main' into add-indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
amjith committed Jun 7, 2022
2 parents f2b147d + 4a751b7 commit fb3409d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

* Add support for ANSI escape sequences for coloring the prompt.
* Add support for `.indexes` command.
* Add an option to turn off the auto-completion menu. Completion menu can be
triggered by pressed the `<tab>` key when this option is set to False. Fixes
[#105](https://github.com/dbcli/litecli/issues/105).

### Bug Fixes

* Fix [#120](https://github.com/dbcli/litecli/issues/120). Make the `.read` command actually read and execute the commands from a file.
* Fix [#96](https://github.com/dbcli/litecli/issues/96) the crash in VI mode when pressing `r`.

## 1.8.0 - 2022-03-29

Expand Down
1 change: 1 addition & 0 deletions litecli/clitoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ def _get_vi_mode():
InputMode.NAVIGATION: "N",
InputMode.REPLACE: "R",
InputMode.INSERT_MULTIPLE: "M",
InputMode.REPLACE_SINGLE: "R",
}[get_app().vi_state.input_mode]
4 changes: 4 additions & 0 deletions litecli/liteclirc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ key_bindings = emacs
# Enabling this option will show the suggestions in a wider menu. Thus more items are suggested.
wider_completion_menu = False

# Autocompletion is on by default. This can be truned off by setting this
# option to False. Pressing tab will still trigger completion.
autocompletion = True

# litecli prompt
# \D - The full current date
# \d - Database name
Expand Down
9 changes: 7 additions & 2 deletions litecli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(
self.cli_style = c["colors"]
self.output_style = style_factory_output(self.syntax_style, self.cli_style)
self.wider_completion_menu = c["main"].as_bool("wider_completion_menu")
self.autocompletion = c["main"].as_bool("autocompletion")
c_dest_warning = c["main"].as_bool("destructive_warning")
self.destructive_warning = c_dest_warning if warn is None else warn
self.login_path_as_host = c["main"].as_bool("login_path_as_host")
Expand Down Expand Up @@ -162,10 +163,11 @@ def register_special_commands(self):
)
special.register_special_command(
self.execute_from_file,
"source",
".read",
"\\. filename",
"Execute commands from file.",
aliases=("\\.",),
case_sensitive=True,
aliases=("\\.", "source"),
)
special.register_special_command(
self.change_prompt_format,
Expand Down Expand Up @@ -549,6 +551,9 @@ def one_iteration(text=None):
else:
complete_style = CompleteStyle.COLUMN

if not self.autocompletion:
complete_style = CompleteStyle.READLINE_LIKE

with self._completer_lock:

if self.key_bindings == "vi":
Expand Down
18 changes: 0 additions & 18 deletions litecli/packages/special/dbcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,24 +237,6 @@ def describe(cur, arg, **_):
return [(None, tables, headers, status)]


@special_command(
".read",
".read path",
"Read input from path",
arg_type=PARSED_QUERY,
case_sensitive=True,
)
def read_script(cur, arg, **_):
args = shlex.split(arg)
if len(args) != 1:
raise TypeError(".read accepts exactly one path")
path = args[0]
with open(path, "r") as f:
script = f.read()
cur.executescript(script)
return [(None, None, None, "")]


@special_command(
".import",
".import filename table",
Expand Down
8 changes: 8 additions & 0 deletions tests/liteclirc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ key_bindings = emacs
# Enabling this option will show the suggestions in a wider menu. Thus more items are suggested.
wider_completion_menu = False

# Autocompletion is on by default. This can be truned off by setting this
# option to False. Pressing tab will still trigger completion.
autocompletion = True

# litecli prompt
# \D - The full current date
# \d - Database name
Expand All @@ -61,9 +65,13 @@ wider_completion_menu = False
# \R - The current time, in 24-hour military time (0-23)
# \r - The current time, standard 12-hour time (1-12)
# \s - Seconds of the current time
# \x1b[...m - insert ANSI escape sequence
prompt = "\t :\d> "
prompt_continuation = "-> "

# Show/hide the informational toolbar with function keymap at the footer.
show_bottom_toolbar = True

# Skip intro info on startup and outro info on exit
less_chatty = False

Expand Down

0 comments on commit fb3409d

Please sign in to comment.