-
Notifications
You must be signed in to change notification settings - Fork 19
Command Line
Naga was built as a set of libraries to provide rules functionality. A command line interface (CLI) has been built to demonstrate how the components in the API can be brought together.
If you want to learn how to use Naga, read this source code.
The command line can be run with one of 2 modes: Logic programming; JSON processing.
When executed without a JSON option on the command line, Naga operates as a Datalog programming interpreter. With no arguments, it will look for the Datalog program on stdin, otherwise it will treat the argument as a path or URL to obtain the program from.
Datalog programs are identical in syntax to Prolog.
All base facts in the program will be asserted in the database. The contents of the database will be written to stdout. Rules will then be executed until completion. At that point the database will contain all of the original and inferred data. The CLI will then print all new statements that did not appear in the database before execution.
When a --json
option is present, the program will look for a path or URL provided in the JSON parameter, and will look for a path provided as the --out
parameter. A remaining argument will be read as the program to be run, or when no argument is present, the program will be read from stdin.
The file provided in the --json
option will be loaded by the data layer and stored in the graph database. The program will be executed against the store. Finally, the data layer will extract everything from the database and convert it to JSON. This will be written to the location specified by --out
.