Skip to content

Commit

Permalink
LangStream Home from Property, support Symlinks (#699)
Browse files Browse the repository at this point in the history
Allow specifying the LangStream home directory, via the
LANGSTREAM_HOME property (or environment variable).

If not specified, continue to use .langstream in the user's
home directory, but allow that to be a symlink. Fixes #697

Co-authored-by: Nick Burch <[email protected]>
  • Loading branch information
Gagravarr and Nick Burch authored Nov 8, 2023
1 parent d362a02 commit 83afc3f
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@

public class LangStreamCLI {

/**
* @return ${LANGSTREAM_HOME} if set, otherwise ${user.home}/.langstream
*/
@SneakyThrows
public static Path getLangstreamCLIHomeDirectory() {
final String langStreamHome = System.getProperty("LANGSTREAM_HOME");
if (langStreamHome != null && !langStreamHome.isBlank()) {
return Path.of(langStreamHome);
}

final String userHome = System.getProperty("user.home");
if (!userHome.isBlank() && !"?".equals(userHome)) {
final Path langstreamDir = Path.of(userHome, ".langstream");
Files.createDirectories(langstreamDir);
if (!Files.exists(langstreamDir)) {
Files.createDirectories(langstreamDir);
}
return langstreamDir;
}
return null;
Expand Down

0 comments on commit 83afc3f

Please sign in to comment.