MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / render_atomic_install_value

Function render_atomic_install_value

atomic-cli/src/commands/update.rs:344–352  ·  view source on GitHub ↗

Render an `ATOMIC_INSTALL=...` value suitable for embedding in a shell snippet. When the directory equals `$HOME/.local/bin` literally we keep the pretty `"$HOME/.local/bin"` form so users can copy it verbatim and have their shell expand `$HOME`. Otherwise we POSIX single-quote the absolute path so it survives copy-paste regardless of what's in it.

(dir: &Path, home: Option<&str>)

Source from the content-addressed store, hash-verified

342/// single-quote the absolute path so it survives copy-paste regardless
343/// of what's in it.
344fn render_atomic_install_value(dir: &Path, home: Option<&str>) -> String {
345 if let Some(h) = home {
346 let home_local_bin = PathBuf::from(h).join(".local").join("bin");
347 if dir == home_local_bin {
348 return r#""$HOME/.local/bin""#.to_string();
349 }
350 }
351 shell_quote(&dir.display().to_string())
352}
353
354/// Produce the multi-line outdated message for a given source. Pure so
355/// the unit tests can match on substrings.

Calls 2

shell_quoteFunction · 0.85
displayMethod · 0.80