Refactor filesystem with pathlib + improve CLI UX #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
08be4aa
This commit refactors the way we interact with the filesystem by replacing the
os.path
module withpathlib.Path
. This makes the code more readable, easier to understand and less error-prone.Key changes include:
LOG_DB
, to represent the path of the log database file. This eliminates the need for theget_log_db_path()
function.os.path.exists
checks with thePath.exists()
method.os.path.expanduser
calls and string concatenations for file paths with the/
operator provided bypathlib.Path
.Path.mkdir()
method for directory creation.llm init-db
, similar to the scenario when~/.llm/log.db
is absent and a chat history needs to be read.These changes should improve the maintainability and readability of the code without altering the functionality.
9cb5224
This commit improves the CLI UX by adding the help text for no-arg scenarios; however, it preserves the pipe compatibility—the prompt can still be manipulated with
--system
.Running
llm
without any arguments no longer causes the program to hang indefinitely.974f9d2
Add a helper message for the
logs
command.This will be displayed in the general
--helper
message.