The JBoss(WildFly) CLI supports variables. Variables may appear in, basically, any part of a command line and will be resolved during the command line parsing phase.
Variables are referenced using '$'. E.g.
$prod_db/statistics=jdbc:read-resource
Here the prod_db variable will be resolved to a node path, to a data-source in this case.
Variables can be initialized using set command, e.g.
[standalone@localhost:9990 /] set prod_db=/subsystem=datasources/data-source=ExampleDS
You can change the value for the existing variable using the same set command and remove (unset) the variable setting it to an empty value
[standalone@localhost:9990 /] set prod_db=
or using unset command
[standalone@localhost:9990 /] unset prod_db
To check which value a variable is set to use echo command
[standalone@localhost:9990 /] echo $prod_db
/subsystem=datasources/data-source=ExampleDS
Each variable-manipulating command may accept multiple arguments, i.e. target multiple variables at the same time, please, refer to their --help descriptions to get familiar with the syntax and supported options.
NOTE: variable names are expected to follow the Java identifier format.
A couple of general examples showing where the variables may appear and that basically the entire command line may consist of variables:
[standalone@localhost:9990 /] $prod_db:$op($param=$param_value)
[standalone@localhost:9990 /] $cmd --$param=$param_value
.jbossclirc file
Variable manipulations (i.e. the effects of set and unset commands) during the command line session won't be persisted when the session is terminated. Which means a newly launched session won't see the effects of those manipulations. There is, however, a way to initialize the environment when a new session is launched. The CLI supports .jbossclirc file (similar to .bashrc) which is optional. The content of the file is a list of CLI supported commands and operations (one per line). This file will be executed when a new session is launched but before the control is given to the user (but also after the system properties specified with --properties argument have been set, if it was present).
The following locations will be checked for the presence of .jbossclirc in the order as they are listed:
- if the system property jboss.cli.rc is defined, its value will be considered a path to the file;
- user's working directory (as defined by user.dir system property);
- JBOSS_HOME/bin directory.
In fact, there is a default .jbossclirc included in the distribution in JBOSS_HOME/bin, which contains only comments and can be used as a template for user-specific environment setup.
Comments