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