Onset: version control where nobody waits and nothing gets lost. The on command, its core and onset-server.
| /// VCS_HOME, else the platform's data folder (~/.local/share/vcs on Linux, |
| 6 | /// ~/Library/Application Support/vcs on macOS, %LOCALAPPDATA%\vcs on Windows). |
| 7 | pub fn home() -> PathBuf { |
| 8 | if let Some(dir) = std::env::var_os("VCS_HOME") { |
| 9 | return PathBuf::from(dir); |
| 10 | } |
| 11 | if cfg!(windows) |
| 12 | && let Some(local) = std::env::var_os("LOCALAPPDATA").filter(|d| !d.is_empty()) |
| 13 | { |
| 14 | return PathBuf::from(local).join("vcs"); |
| 15 | } |
| 16 | let user = crate::sys::user_home().unwrap_or_else(|| ".".into()); |
| 17 | if cfg!(target_os = "macos") { |
| 18 | return user.join("Library/Application Support/vcs"); |
| 19 | } |
| 20 | match std::env::var_os("XDG_DATA_HOME") { |
| 21 | Some(d) if !d.is_empty() => PathBuf::from(d).join("vcs"), |
| 22 | _ => user.join(".local/share/vcs"), |
| 23 | } |
| 24 | } |
| 25 |
| 26 | pub fn objects() -> PathBuf { |
| 27 | home().join("objects") |
| 28 | } |
| 29 |
| 30 | /// Sign-in tokens, readable only by the user. |
| 31 | pub fn credentials() -> PathBuf { |
| 32 | home().join("credentials.json") |
| 33 | } |
| 34 |