use crate::config::Config;
use crate::model::Tier;
use crate::model::doctype::{Form, KeyKind, TypeDef};
use crate::workspace::{Owner, Owners};
pub fn stem(ty: &TypeDef, key: &str, slug: &str) -> String {
match ty.key {
KeyKind::Stamp => format!("{key}-{slug}"),
KeyKind::Slug => slug.to_string(),
}
}
pub fn type_dir(cfg: &Config, owners: &Owners, owner: &Owner, tier: Tier, ty: &TypeDef) -> String {
match tier {
Tier::Committed => format!("{}/{}", owners.spec_dir(owner, cfg.spec_dir()), ty.name),
Tier::Local => format!("{}/{}/{}", cfg.local_dir(), owner.id, ty.name),
}
}
pub fn main_file(type_dir: &str, ty: &TypeDef, stem: &str, bundle: bool) -> String {
if bundle || ty.form == Form::Dir {
format!("{type_dir}/{stem}/index.{}.md", ty.name)
} else {
format!("{type_dir}/{stem}.{}.md", ty.name)
}
}