mirror of
https://github.com/apple/pkl.git
synced 2026-08-27 06:04:03 +02:00
Use XDG base directories and Known Folders on Windows (#1809)
This changes logic that previously read/wrote from `~/.pkl` to use XDG base directories (all OSes), and Known Folders locations on Windows. For example, Pkl will look for `settings.pkl` in: 1. `$XDG_CONFIG_HOME/pkl/settings.pkl` 2. `%APPDATA/pkl/settings.pkl` 3. `~/.pkl/settings.pkl` 4. Path pkl/settings/pkl within `$XDG_CONFIG_DIRS` 5. `/etc/xdg/pkl/settings.pkl` --------- Co-authored-by: Florin Ungur <florin@florinungur.com>
This commit is contained in:
co-authored by
Florin Ungur
parent
4dd37219c0
commit
6551a59f9e
@@ -63,7 +63,11 @@ internal class Repl(workingDir: Path, private val server: ReplServer, private va
|
||||
}
|
||||
completer(AggregateCompleter(CommandCompleter, FileCompleter(workingDir)))
|
||||
option(Option.DISABLE_EVENT_EXPANSION, true)
|
||||
variable(LineReader.HISTORY_FILE, (IoUtils.getPklHomeDir().resolve("repl-history")))
|
||||
// Will be null if `user.home` property is not set.
|
||||
// If so, don't bother writing repl history.
|
||||
IoUtils.getReplHistoryFile()?.let { historyFile ->
|
||||
variable(LineReader.HISTORY_FILE, historyFile)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
||||
@@ -80,7 +84,7 @@ internal class Repl(workingDir: Path, private val server: ReplServer, private va
|
||||
|
||||
fun run() {
|
||||
// JLine 2 history file is incompatible with JLine 3
|
||||
IoUtils.getPklHomeDir().resolve("repl-history.bin").deleteIfExists()
|
||||
IoUtils.getLegacyPklHomeDir().resolve("repl-history.bin").deleteIfExists()
|
||||
|
||||
println(ReplMessages.welcome)
|
||||
println()
|
||||
|
||||
Reference in New Issue
Block a user