The command line
rego4k is a command line with the commands of opa that rego4k shares with OPA, and the commands of rego4k.
- The commands of
opahave OPA's flags, output and exit codes. - The commands of rego4k are signed decisions, tree shaking and the decision server.
A test of rego4k-cli-opa runs 216 command lines through opa and rego4k, and compares them.
Run it
just cli builds the jar and its start script, and prints the path of the script.
just is a command runner, as make is. rego4k needs Java 21 or later.
just cli
rego4k eval -d policies -i input.json -f pretty data.authz.allow
rego4k test -v policies
rego4k fmt -l policies
rego4k run --server -b bundle.tar.gz --with-debugger --with-shaking
rego4k shake -e authz/allow -o shaken.tar.gz bundle.tar.gz
rego4k sign-decision authz/allow -b bundle.tar.gz -i input.json --signing-key leaf.key --signing-algorithm ES256| Command | Module | What it does |
|---|---|---|
eval, check, fmt, parse, test, build |
rego4k-cli-opa |
The commands of opa, with OPA's flags. A flag of OPA that rego4k does not support is an error. |
sign-decision, verify-decision, reproduce-decision, sign-input |
rego4k-cli-decision-signing |
Signed decisions and signed inputs. |
shake |
rego4k-cli-shaking |
Tree shaking of a bundle for its entrypoints, its dry run, and with --wasm, new wasm modules. |
run --server |
rego4k-cli-server |
The decision server, with the flags of opa run --server that it can honour. |
The README of each module lists its flags. Divergences from OPA lists the differences of the output.
Your own command line
Cli runs the command that a command line names, and each module gives its commands as a list. An application can
make a command line with its own builtins, or with only some commands:
val hello = Builtin.Pure("greetings.hello", 1) { args ->
Str("hello ${args.str(0)}")
}
val cli = Cli(opaCommands(Rego(Builtins.Pure.stdlib(Re2Engine) + hello)))
// fun main(args: Array<String>) {
// exitProcess(cli.run(args.toList(), Console.standard()))
// }OwnCommandLine.kt, lines 20 to 26, on GitHubCli.run gives the exit code of the command. An error of the command line prints Error: <message> and the
usage of the command, with the exit code 1, as opa does.