use super::{ItemEdit, NewItem, add_item, init_board};
use crate::backlog::{BacklogItem, ItemId};
use crate::config::Config;
use std::path::Path;
use tempfile::TempDir;
pub(super) async fn init_temp() -> TempDir {
let dir = TempDir::new().expect("temp dir");
init_board(dir.path()).await.expect("init");
dir
}
pub(super) async fn add_with(
dir: &Path,
title: &str,
labels: &[&str],
sprint: Option<&str>,
) -> BacklogItem {
let new = NewItem {
points: None,
labels: labels
.iter()
.map(std::string::ToString::to_string)
.collect(),
sprint: sprint.map(std::string::ToString::to_string),
body: String::new(),
parent: None,
depends_on: Vec::new(),
};
add_item(dir, title, new).await.expect("add succeeds")
}
pub(super) async fn set_columns(dir: &Path, columns: &[&str]) {
let path = dir.join(".pinto").join("config.toml");
let mut config = Config::load(&path).await.expect("load config");
config.columns = columns
.iter()
.map(std::string::ToString::to_string)
.collect();
config.save(&path).await.expect("save config");
}
pub(super) fn parent_edit(parent: Option<ItemId>) -> ItemEdit {
ItemEdit {
parent: Some(parent),
..Default::default()
}
}