pub fn quote_for_context(value: &str, context: QuoteContext) -> StringExpand description
Quote a value for the context it is interpolated into.
In an unquoted position this is plain quote. Inside quotes the value is
inserted as escaped literal text, without adding another layer of quotes.
ยงExamples
use command_stream::quote::{quote_for_context, QuoteContext};
assert_eq!(quote_for_context("hello world", QuoteContext::Unquoted), "'hello world'");
assert_eq!(quote_for_context("hello world", QuoteContext::Double), "hello world");
assert_eq!(quote_for_context("it's", QuoteContext::Single), "it'\\''s");