XWiki CLI

Last modified by Thomas Mortagne on 2026/08/06 16:16

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.

sudo apt install build-essential libz-dev
curl -s "https://get.sdkman.io" | bash
sdk list java
sdk install java 23-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/23-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

List properties of Main.WebHome and their values:

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

Set the code property value:

xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -p 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 -p 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 -p Main.WebHome --get-content

Set the content of the page:

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

Set the title of the page:

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

Mount a wiki as a FUSE filesystem:

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

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

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).

Sync a maven repository to a directory hierarchy in the XFF format and all changes on the XFF directory will update the maven repository

mkdir -p ~/xwiki_cli_sync
xwiki-cli --pom --sync-daemon --cli-dir /home/user/xwiki_cli_sync --mvn-repo /home/user/My/Mvn/Repository

Sync a maven repository to a directory hierarchy in the XFF format and all changes on the XFF directory will update the maven repository and the wiki

mkdir -p ~/xwiki_cli_sync
xwiki-cli --pom --sync-daemon --cli-dir /home/user/xwiki_cli_sync --mvn-repo /home/user/My/Mvn/Repository --user Admin --pass admin --url http://localhost:8080/xwiki

Extensions

This project contains the following Extensions.

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

Versions

Get Connected