specfold_core/placement/
paths.rs1use crate::config::Config;
4use crate::model::Tier;
5use crate::model::doctype::{Form, KeyKind, TypeDef};
6use crate::workspace::{Owner, Owners};
7
8pub fn stem(ty: &TypeDef, key: &str, slug: &str) -> String {
10 match ty.key {
11 KeyKind::Stamp => format!("{key}-{slug}"),
12 KeyKind::Slug => slug.to_string(),
13 }
14}
15
16pub fn type_dir(cfg: &Config, owners: &Owners, owner: &Owner, tier: Tier, ty: &TypeDef) -> String {
18 match tier {
19 Tier::Committed => format!("{}/{}", owners.spec_dir(owner, cfg.spec_dir()), ty.name),
20 Tier::Local => format!("{}/{}/{}", cfg.local_dir(), owner.id, ty.name),
21 }
22}
23
24pub fn main_file(type_dir: &str, ty: &TypeDef, stem: &str, bundle: bool) -> String {
27 if bundle || ty.form == Form::Dir {
28 format!("{type_dir}/{stem}/index.{}.md", ty.name)
29 } else {
30 format!("{type_dir}/{stem}.{}.md", ty.name)
31 }
32}