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.
As root:
sudo apt install build-essential libz-dev zipAnd 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-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/25-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
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.spaceDo 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.
mkdir -p ~/xwiki_cli_sync
xwiki-cli --edit-tree --working-directory /home/user/xwiki_cli_sync --mvn-repo /home/user/My/Mvn/RepositoryDo 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.spaceList properties of Main.WebHome and their values:
xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --list-propertiesSet 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 nanoGet the content of the page:
xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --get-contentSet 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:
mkdir -p /tmp/xwikimount
xwiki-cli --user Admin --pass admin --url http://localhost:8080/xwiki -r Main.WebHome --mount /tmp/xwikimountNote: you need to install fuse2 (on Debian and its derivatives: apt install libfuse2).
Extensions
This project contains the following Extensions.
| per page of Previous Page Next Page Page | ||||||||||||||||||
|
||||||||||||||||||
| Previous Page Next Page Page | ||||||||||||||||||