XWiki CLI

Last modified by Raphaël Jakse on 2026/09/25 11:03

cogXWiki CLI is a command-line tool to manipulate XWiki content on XWiki instances and extension repositories
TypeProject
Last versionUnknown
LicenseGNU Lesser General Public License 2.1

Description

XWiki CLI is a command-line tool to manipulate XWiki content on XWiki instances and extension repositories. It aims at:

    improving experience when developping on top of XWiki
    providing tools to automatise actions on XWiki content

Contrary to most other XWiki contrib packages, it runs outside XWiki. It is not a XWiki extension.

For now the documentation is quite bare and XWiki CLI is in a prototype state but it will be improved.

Requirement

XWiki-CLI requires Java 17. Building a fast and convenient binary requires GraalVM, but this is not needed for development.

Build

First, clone the repository.

XWiki contributors:

git clone [email protected]:xwiki-contrib/cli.git

Or, anybody:

git clone https://github.com/xwiki-contrib/cli.git

Then, change directory to the cloned repository:

cd cli

Standard Maven build (without GraalVM)

This is suitable when developing because the build is faster, or when one hasn't setup GraalVM yet, but produces something slower and less convenient to use.

mvn install

When building this way, CLI can be used by changing to the root of its repository and by running:

java -cp target/cli-1.0-SNAPSHOT.jar org.xwiki.contrib.cli.Main ...ARGS....

GraalVM build

This is suitable after a development session or for releases. It produces a single, convenient and faster binary. It requires GraalVM.

Warning

xwiki-cli has mostly been tested built without GraalVM. Some stuff might not work properly. We expect the GraalVM builds to work fine though.

Installing GraalVM

Please use the official instructions. For convenience, we give some instructions for Debian here anyway to know roughly what to do, but we don't guarantee they work well.

Building XWiki CLI using GraalVM requires GCC. We recommend installing build-essential. It also requires the development package of libz.

SDKMan will then allow you to install a GraalVM distribution easily.

As root:

sudo apt install build-essential libz-dev zip

And then as your normal user:

curl -s "https://get.sdkman.io" | bash
. "$HOME"/.sdkman/bin/sdkman-init.sh # mind the dot at the start
sdk list java
sdk install java 25-graal

Then, make sure JAVA_HOME points to your newly installed GraalVM distribution.

export JAVA_HOME=~/.sdkman/candidates/java/current/

Or, more explicitly:

export JAVA_HOME=~/.sdkman/candidates/java/25-graal/

Then, compile:

mvn -Pnative package -DskipTests=true

If you have make, you can instead run:

make exe

Refer to the Makefile file for more information on what you can run.

Then, a xwiki-cli binary is produced in the target folder:

 
./target/xwiki-cli --help

You can install it by copying the binary to some folder in your PATH.

See what folders are in your PATH:

 
echo $PATH

Install xwiki-cli in your home folder (caution, /.local/bin is not always in PATH by default, but you can add it by editing your shell's rc file):

 
cp target/xwiki-cli ~/.local/bin

Install xwiki-cli system-wide:

 
sudo cp target/xwiki-cli /usr/local/bin/

Get help

Warning

The following assumes you have a xwiki-cli binary built using GraalVM, or a script named xwiki-cli in your PATH that calls the right Main class in the right current folder.

If you are compiling XWiki CLI without GraalVM, replace:

xwiki-cli

with:

java -cp target/cli-1.0-SNAPSHOT.jar org.xwiki.contrib.cli.Main

in the following examples.

List the supported features and parameters:

xwiki-cli --help

Use the guide

If you run xwiki-cli without any parameter, it will propose you to run the guide by typing guide.
It will help you build a configuration file for one of the examples of sync mode listed below.

At the next run, if it detects the configuration file, it will read that file for setting the command parameters.

Examples

Do a bidirectional synchronization. This will create directory hierarchy in the XFF format and a Java project (for all Java stuff like Groovy macro, script components, velocity macros) at the startup based on the maven repository content. Then the changes done in each hierarchy (in XFF, Java project, maven repository and the XWiki instance) will be replicated at the others places. All pages added in the space Example.space in the running XWiki instance will be added automatically to the maven repository.

mkdir -p ~/xwiki_cli_sync
xwiki-cli --edit-tree --working-directory /home/user/xwiki_cli_sync --mvn-repo /home/user/My/Mvn/Repository -u http://localhost:8080/xwiki --user Admin --pass admin --spaces Example.space

Do a bidirectional synchronization. This will create directory hierarchy in the XFF format and a Java project (for all Java stuff like Groovy macro, script components, velocity macros) at the startup based on the maven repository content. Then the changes done in each hierarchy (in XFF, Java project and maven repository) will be replicated at the others places.

Information

Note that doing not providing a XWiki instance will have some limitation. For instance adding an object is not supported because it require a XWiki instance to retrieve the class structures.

mkdir -p ~/xwiki_cli_sync
xwiki-cli --edit-tree --working-directory /home/user/xwiki_cli_sync --mvn-repo /home/user/My/Mvn/Repository

Do a bidirectional synchronization. This will create directory hierarchy in the XFF format and a Java project (for all Java stuff like Groovy macro, script components, velocity macros) at the startup based on the XWiki instance content for the space Example.space. Then the changes done in each hierarchy (in XFF, Java project and maven repository) will be replicated at the others places.

mkdir -p ~/xwiki_cli_sync
xwiki-cli --edit-tree --working-directory /home/user/xwiki_cli_sync -u http://localhost:8080/xwiki --user Admin --pass admin --spaces Example.space

List properties of Main.WebHome and their values:

xwiki-cli --user Admin --pass admin  --url http://localhost:8080/xwiki -r Main.WebHome --list-properties

Set the code property value:

xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --set-property code -v "#xwikicontent { color: pink }"

With the nano editor, edit the code property of the second XWiki.ScriptComponentClass object (save the temporary file and quit the process after):

xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome -o XWiki.ScriptComponentClass/1 --edit-property code -o 0 --editor nano

Get the content of the page:

xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --get-content

Set the content of the page:

xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --set-content "HELLO"

Set the title of the page:

xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --set-title "My title"

Mount a wiki as a FUSE filesystem:

Warning

The FUSE implementation is experimental and unstable. We are working on another, simpler and more robust, solution that eagerly produces an editable folder, watched by XWiki CLI.

This feature might be depreciated at some point in favour to the sync feature. But currently it still be really useful when we need to retrieve the content from the wiki (instead of the maven repository).

mkdir -p /tmp/xwikimount
xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --mount /tmp/xwikimount

Note: you need to install fuse2 (on Debian and its derivatives: apt install libfuse2).

Extensions

This project contains the following Extensions.

per page of Page
Warning
The environment prevents the table from loading data.
 
Page

Versions

Get Connected