JR is a CLI program that helps you to create quality random data for your applications.
JR requires Go 1.20
you can use the make_install.sh
to install JR. This script does everything needed in one simple command.
./make_install.sh
These are the steps in the make_install.sh
script if you want to use them separately:
make all
make copy_templates
sudo make install
If you want to run the Unit tests, you have a make
target for that too:
make test
JR is very straightforward to use. Here are some examples:
jr list
Templates are in the directory $HOME/.jr/templates
. You can override with the --templatePath
command flag
Templates with parsing issues are showed in red, Templates with no parsing issues are showed in green
Use for example the predefined net_device
template to generate a random JSON network device
jr template run net_device
If you want to use your own template, you have several options:
- put it in the default directory
- put it in another directory and use the
--templateDir
flag - put it in another directory and use the
--templateFileName
flag to directly refer to it - embed it directly in the command using the
--template
flag
For a quick and dirty test, a good option is to directly point to a template:
jr template run --templateFileName ~/.jr/templates/user.tpl
For an even quicker and dirtier test, the best option is to embed directly a template in the command:
jr template run --template "name:{{name}}"
Using -n
option you can create more data in each pass.
This example creates 3 net_device objects at once:
jr template run net_device -n 3
Using --frequency
option you can repeat the creation every f
milliseconds
This example creates 2 net_device every second, for ever:
jr template run net_device -n 2 -f 1s
Using --duration
option you can time bound the entire object creation.
This example creates 2 net_device every 100ms for 1 minute:
jr template run net_device -n 2 -f 100ms -d 1m
Results are by default written on standard out (--output "stdout"
) with this output template:
"{{.V}}\n"
which means that only the "Value" is in the output. You can change this behaviour embedding a different template with --outputTemplate