Closed mjpieters closed 1 year ago
I can confirm that changing unset_once_if_written
to:
@export
def unset_once_if_written():
"""Unset the once file, if it has been written to."""
global once_file, written_to_once_file
if written_to_once_file:
once_file = written_to_once_file = None
fixes the issue. Clearing written_to_once_file
makes sure that the trigger doesn't fire forever for later commands.
I expect the
.once
command to work more than once in a session, each time resulting in the next query output to be written to a designated file.Instead, you can use
.once
just once in a session. After that you have to restart litecli. It doesn't matter what the arguments are; executing.once
a second time in the same session has no effect.This is caused by the
written_to_once_file
flag; it is set toTrue
when output is sent to a file, but then never set back toFalse
.With
written_to_once_file
set toTrue
, the next time you execute.once
, theset_once()
command still setsonce_file
, but immediately afterwards,unset_once_if_written()
is executed after the command completes, which setsonce_file
back toNone
, so by the time your next output-producing command is run, nothing will be written out to the file.