Skip to content

startup_commands fails when config value is a single string. #176

@gvoysey

Description

@gvoysey

Using litecli version 1.10.1, installed with pipx on linux; base python is a pyenv-installed 3.10.10.

Given the following contents of ~/.config/litecli/config:

[startup_commands]
commands = ".tables"

loading litecli fails:

.
Could not execute all startup commands:
Not connected to database.
(none)>

If the config is changed to add a trailing comma:

[startup_commands]
commands = ".tables",

then the .tables command is correctly executed.

I suspect this is because without the comma, python is iterating the over the string ".tables", not the list [".tables",]:

litecli/litecli/main.py

Lines 591 to 596 in 9d5bcf0

for command in self.startup_commands["commands"]:
try:
res = sqlexecute.run(command)
except Exception as e:
click.echo(command)
self.echo(str(e), err=True, fg="red")

Adding a print above L592 confirms.
Without a comma:
self.startup_commands={'commands': '.tables'}

With a comma:
self.startup_commands={'commands': ['.tables']}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions