openlifa.openmui
importopenmui: a user interface as one semantic tree --- an OpenLifa specification, its C ABI and its C++ module
import openmui.spec;
模块名取自本索引给这个包写的测试项目。
mcpp add openlifa.openmui@0.4.1
用法
来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。
import std;
import openmui.spec;
namespace spec = omui::spec;
int main() {
const auto actor = spec::Actor::parse("agent:reader;via=person:alice,agent:planner");
if (!actor || actor->via.size() != 2 || actor->text() != "agent:reader;via=person:alice,agent:planner") return 1;
spec::SemanticNode n;
n.id = "notes/delete";
n.role = spec::Role::button;
n.name = "Delete";
n.actions.push_back({.name = "activate", .effect = spec::Effect::irreversible, .verb = "note.delete", .answer = "yes"});
if (!spec::check(n).empty()) return 2;
if (spec::catalog::find("slider") == nullptr) return 3;
spec::Envelope e;
e.error(spec::error_code::needs_answer, "confirm").result(spec::exit_code::needs_answer);
if (e.exit_code() != 2) return 4;
std::println("{}", e.ndjson());
return 0;
}
tests/examples/openlifa.openmui/tests/consume.cpp · 项目 tests/examples/openlifa.openmui
构建 · 上游清单
- targets
openmui-spec (lib)- manifest version
0.4.1- 来源
https://raw.githubusercontent.com/openlifa/openmui/0.4.1/mcpp.toml