kodumaro_http_cli/cli/util.rs
1use std::fs::read_to_string;
2
3use eyre::Result;
4
5pub fn parse_string(value: impl ToString) -> Result<String> {
6 let value = value.to_string();
7 if let Some(value) = value.strip_prefix('@') {
8 Ok(read_to_string(value)?.trim().to_owned())
9 } else {
10 Ok(value)
11 }
12}
13
14
15pub fn extension_from_mime(mime: &str) -> &'static str {
16 if mime.contains("json") {
17 return ".json";
18 }
19 if mime.contains("xml") {
20 return ".xml";
21 }
22 ".txt"
23}