WIP - Configurable auto-backup files#10
Conversation
sysread
left a comment
There was a problem hiding this comment.
Some initial thoughts. I'm still thinking through the different modes and how they are represented in the code base, but as you said, this PR is still early stage.
|
|
||
| defp backup_guidance do | ||
| if Settings.should_create_backup_files?() do | ||
| "If backup files are available to the user, you may revert changes by replacing the file with the latest `.bak` file." |
There was a problem hiding this comment.
| "If backup files are available to the user, you may revert changes by replacing the file with the latest `.bak` file." | |
| "You can revert changes by replacing the file with the latest `.bak` file." |
Since it's conditionally injected, it doesn't need to hedge.
|
|
||
| display_path = | ||
| case Store.get_project() do | ||
| {:ok, project} when is_binary(project.source_root) -> |
There was a problem hiding this comment.
I don't think you need the is_binary guard. If you have backups, you are in an ask session, which requires a --project (or guesses it based on your cwd). And a project should always have a valid source_root.
| Get the list of global configuration keys that should not be treated as project names. | ||
| """ | ||
| @spec global_config_keys() :: [binary] | ||
| def global_config_keys() do |
There was a problem hiding this comment.
This section needs to be mix formated.
| {:ok, %{"name" => name}} -> | ||
| # Project exists but has no edit-mode map | ||
| _ = name | ||
| nil |
There was a problem hiding this comment.
| {:ok, %{"name" => name}} -> | |
| # Project exists but has no edit-mode map | |
| _ = name | |
| nil | |
| # Project exists but has no edit-mode map | |
| {:ok, %{"name" => _}} -> | |
| nil |
| is_binary(project_value) -> | ||
| project_value | ||
|
|
||
| is_map(Settings.get(settings, "edit-mode", nil)) and is_binary(Map.get(Settings.get(settings, "edit-mode", %{}), "backup-file-handling")) -> |
There was a problem hiding this comment.
This is super hard to read and visually parse.
Working on making the auto-created backup files configurable.
Backup file behavior is controlled by the
edit-mode.backup-file-handlingsetting in~/.fnord/settings.json.Valid values are:
never-createauto-deleteask-to-deletecreate-and-ignoreExample:
{ "edit-mode": { "backup-file-handling": "ask-to-delete" } }Default behavoir when
edit-mode.backup-file-handlingis not present is to keep the status quo: Create the backups and offer to delete them