XWiki CLI
| XWiki CLI is a command-line tool to manipulate XWiki content on XWiki instances and extension repositories |
Table of contents
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.gitOr, anybody:
git clone https://github.com/xwiki-contrib/cli.gitThen, change directory to the cloned repository:
cd cliStandard 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 installWhen 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.
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-graalThen, 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=trueIf you have make, you can instead run:
make exeRefer 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 --helpYou can install it by copying the binary to some folder in your PATH.
See what folders are in your PATH:
echo $PATHInstall 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/binInstall xwiki-cli system-wide:
sudo cp target/xwiki-cli /usr/local/bin/Get help
List the supported features and parameters:
xwiki-cli --helpUse 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-propertiesSet 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 nanoGet the content of the page:
xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -p Main.WebHome --get-contentSet 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/xwikimountNote: you need to install fuse2 (on Debian and its derivatives: apt install libfuse2).
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/RepositorySync 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/xwikiExtensions
This project contains the following Extensions.
| per page of Previous Page Next Page Page | ||||||||||||||||||
|
||||||||||||||||||
| Previous Page Next Page Page | ||||||||||||||||||