()
| 3 | use crate::Result; |
| 4 | |
| 5 | pub(super) fn paths() -> Result<Vec<PathBuf>> { |
| 6 | let mut paths = Vec::new(); |
| 7 | let mut seen = HashSet::new(); |
| 8 | if let Ok(env_paths) = env::var("OPENCODE_DATA_DIR") { |
| 9 | for raw in env_paths |
| 10 | .split(',') |
| 11 | .map(str::trim) |
| 12 | .filter(|path| !path.is_empty()) |
| 13 | { |
| 14 | let path = PathBuf::from(raw); |
| 15 | if path.is_dir() && seen.insert(path.clone()) { |
| 16 | paths.push(path); |
| 17 | } |
| 18 | } |
| 19 | return Ok(paths); |
| 20 | } |
| 21 | |
| 22 | let home = |
| 23 | crate::home::home_dir().ok_or_else(|| crate::cli_error("home directory is not set"))?; |
| 24 | let path = home.join(".local/share/opencode"); |
| 25 | if path.is_dir() && seen.insert(path.clone()) { |
| 26 | paths.push(path); |
| 27 | } |
| 28 | Ok(paths) |
| 29 | } |
no test coverage detected