mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-12 20:52:24 +00:00
Add format_new_item function
This commit is contained in:
parent
f799353aae
commit
3da38ffaa5
1 changed files with 13 additions and 1 deletions
|
@ -41,8 +41,20 @@ pub fn diff_items(old: ShopItem, new: ShopItem) -> Option<String> {
|
||||||
Some(result.join("\n"))
|
Some(result.join("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn format_new_item(item: ShopItem) -> String {
|
||||||
|
format!(
|
||||||
|
"*New item added:* {full_name}\n*Description:* {description}\n*Price:* {price}\n*Stock:* {stock}",
|
||||||
|
full_name = item.full_name,
|
||||||
|
description = item.description.unwrap_or("_not set_".into()),
|
||||||
|
price = item.price,
|
||||||
|
stock = item.stock
|
||||||
|
.map(|stock| stock.to_string())
|
||||||
|
.unwrap_or("Unlimited".into()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod diff_tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue