Skip to main content

Managing configuration

Hakutest offers two ways to manage the configuration:

  • Manually editing the configuration file.
  • Using the config command.

Using config command

Syntax: hakutest config [field] [value].

The hakutest config command is used to manage the configuration for Hakutest via the command line interface. It provides functionality for printing and updating configuration fields. This command has three different uses depending on the number of arguments provided.

info

To use commands without specifying full path to the executable, add Hakutest installation directory to $PATH:

export PATH="$PATH:path/to/hakutest/installation"

If no arguments are provided, the command will print the entire config to the console. The printed config includes tables and other formatting for better readability.

Example:

Command
hakutest config
Output
server
Key Value
mode release
port 8080

general
Key Value
results_directory ./data/results
tests_directory ./data/tests

If a single argument <field> is provided, the command will print only the specified field of the config. It can also log an entire category by specifying the category name.

Example (specific field):

Command
hakutest config server.port
Output
8080

Example (category):

Command
hakutest config server
Output
Key   Value
port 8080
mode release

Update configuration

If two arguments are provided, the command will update the configuration by setting the specified <field> to the specified <value>.

Example:

Command
hakutest config server.port 8000

This command will update config and set field server.port to 8000. You can validate that the value was set properly by running:

Command
hakutest config server.port

It should output the updated value:

Output
8000
warning

hakutest config can only set values for primitive fields and cannot change values within sub-branches. For instance, the following command will result in error:

Command
hakutest config server some_value
Output
2023/11/18 20:55:27 can only set primitive values
exit status 1