forked from EduCraft/curriculum-project-hub
feat(cli): cph init / cph add 子命令(工程脚手架)
init 生成可 check 的工程根(manifest.toml + .cph-version + 默认 exports/student.typ + 空 kind 目录); add 按 kind 建 part 目录/element.toml/必填内容文件并追加 [[parts]]。均纯本地,不涉及 hub 语义; Engine 改惰性构造。cph-schema 新增 required_content_field_names() 作为 add 建文件合同。
This commit is contained in:
@@ -155,6 +155,19 @@ impl KindSchema {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The names of the **required** content fields (those in the schema's
|
||||
/// `required` list), in schema order. The `cph-cli add` authoring surface
|
||||
/// uses this to scaffold the sibling `<field>.typ` files a new part must
|
||||
/// have (ADR-0008): an optional content field (e.g. a lemma's `proof`) is
|
||||
/// not created, so a freshly added part stays schema-legal.
|
||||
pub fn required_content_field_names(&self) -> Vec<&str> {
|
||||
self.content_fields
|
||||
.iter()
|
||||
.filter(|f| f.required)
|
||||
.map(|f| f.name.as_str())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The names of the scalar fields (those living in `element.toml`), in
|
||||
/// schema order.
|
||||
pub fn scalar_field_names(&self) -> Vec<&str> {
|
||||
|
||||
Reference in New Issue
Block a user