Skip to content

cli: Store history file in $XDG_STATE_HOME/$HOME/.local/state #79

Description

@llucax

What's needed?

We need a better location for the dispatch CLI history. Right now it's being stored in $HOME/.dispatch_cli_history.txt, but there is a tendency to avoid polluting homes with these kind of files.

Proposed solution

Use the XDG standard location for state files: $XDG_STATE_HOME, or it's defined default $HOME/.local/state if that variable is not set.

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

  • actions history (logs, history, recently used files, …)

  • current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

Alternatively we can use the https://pypi.org/project/xdg-base-dirs/ which provides an easy access to the XDG env variables or defaults if the env variables are missing.

As for the file name, I would probably use the frequenz namespace too, and maybe even more namespacing too, maybe something like $XDG_STATE_HOME/frequenz/dispatch/cli/history (as we already need to make sure we create the directory anyway, as opposed to the current location ($HOME), $XDG_DATA_HOME might not exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:cliAffects the command-line interfacepriority:❓We need to figure out how soon this should be addressedtype:enhancementNew feature or enhancement visitble to users

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions