- Lua 96.4%
- Shell 2.5%
- Makefile 1.1%
| .github | ||
| config | ||
| dispatch | ||
| docs | ||
| scripts | ||
| test | ||
| .fragjan | ||
| .gitignore | ||
| .merkwerk | ||
| .version_history | ||
| init.lua | ||
| LICENSE | ||
| Makefile | ||
| prompt.lua | ||
| README.md | ||
| render.lua | ||
| VERSION | ||
daw-modul-berhtjan-cli
Terminal renderer for berhtjan UI contributions.
daw-modul-berhtjan-cli renders composed contributions from
daw-modul-berhtjan-core
in the terminal -- prompts, record views, tables and command dispatch --
so a host program never has to implement its own CLI logic.
Status: In development · Lua: 5.1 / 5.4 · License: ISC
❤️ Contribute and support our work
What is daw-modul-berhtjan-cli?
daw-modul-berhtjan-cli is the terminal renderer of the berhtjan UI
layer. It knows no field type names -- every value is read and
displayed generically as text, regardless of what field.type means
in the domain. Commands, subcommands, and their order come from
daw-modul-berhtjan-core's build_index()/sorted_subcommands().
What problem does it solve?
Without it, every host program would need its own CLI dispatch logic
-- argument parsing, subcommand selection, table output, language
resolution. daw-modul-berhtjan-cli does this once, generically, for
every Dragons@Work module: a module ships a contribution.json, and
it becomes usable in the terminal automatically -- without
daw-modul-berhtjan-cli ever needing a change.
Status
- In active development, Lua 5.1 and 5.4 supported
- Fully migrated to
daw_error/v1(structured error objects) and the current daw-modul-berhtjan-core contract (resolve_lang/resolve_labelwithdefault_lang, centralizedsorted_subcommands()) - Known limitation:
default_langmust be supplied by the host/adapter viactx.default_lang-- daw-modul-berhtjan-cli owns no configuration itself
Installation
daw-modul-berhtjan-cli is included as a git dependency, not installed via a package manager:
git clone https://smida.dragons-at-work.de/DAW/daw-modul-berhtjan-cli.git \
lib/daw/berhtjan_cli
Usage
local cli = require("daw.berhtjan_cli")
-- render field labels as a form overview
local ok, err = cli.render_form(composed, lang, default_lang)
-- render a single record
local ok, err = cli.render_record(data, fields)
-- render a list of records as a table
local ok, err = cli.render_table(rows, fields)
-- prompt the user for all fields
local values, err = cli.prompt(composed, groups, lang, default_lang)
-- ask for confirmation
local yes, err = cli.confirm("Really delete?")
-- dispatch a command line to the matching module
local ok, err = cli.dispatch(args, roots, ctx)
composed is the result of daw-modul-berhtjan-core's compose().
fields is a list of field definitions from
composed.groups.*.fields. All runtime I/O goes through
daw.common.sys -- never directly through io.* (tests
inject/capture io.stdin/io.stdout deliberately, that's test code
only).
Every public function follows the
daw_error/v1
contract: value, nil | nil, daw_error/v1 -- never a raw error string.
Documentation
daw_error/v1-- error contractdaw_field_type/v1-- field type contract (why the CLI doesn't need to know field type names)- daw-modul-berhtjan-core -- composer and field type registry
Development and Testing
Requirements: Lua 5.1 or 5.4,
daw-lua-common,
daw-modul-berhtjan-core.
git clone https://smida.dragons-at-work.de/DAW/daw-modul-berhtjan-cli.git
cd daw-modul-berhtjan-cli
git clone https://smida.dragons-at-work.de/DAW/daw-lua-common.git lib/daw/common
git clone https://smida.dragons-at-work.de/DAW/daw-modul-berhtjan-core.git lib/daw/berhtjan_core
make test
echo "DAW_LUA_VERSION = 5.1" > config/local.mk && make test # check against Lua 5.1
Contributing
Bug reports, tests, feedback, and contributions are welcome.
The primary development repository is on Forgejo: Development repository
The GitHub repository is a public mirror for better discoverability. Please submit issues and contributions to the primary repository.
Open Knowledge Needs People
We develop ideas, share knowledge, and build open source software and tools. Projects like this one don't grow on their own -- they live because people ask questions, experiment, share knowledge, find bugs, and help make things better.
You can contribute in different ways:
- reporting bugs
- reviewing code
- testing on other platforms
- improving documentation
- translating content
- or, if you like, supporting us financially
Every contribution helps us keep developing open knowledge and open source software.
Contribute and support our work →
License
Released under the ISC License as part of the Dragons@Work open source ecosystem.