H5P Command Line Interface
A prerequisite for making the h5pcli work is to have nodeJS installed, so if you haven't got this already, head on over to nodeJS first.
When you got npm the easiest way to install h5pcli is by running the following in your favourite command line interface:
npm install -g h5p
This makes npm install h5pcli globally, we have to install it globally to use it in our favourite shell or command line interface.To get the latest h5p version, you can also grab it at Github.
Now that you have installed h5pcli globally on your computer you can use it in your command line by typing h5p.
The main usage areas for the cli are git interactions with library repositories.
This will bring up the available commands:
- help <command> Displays additional information
- list List all H5P libraries
- get <library> Clone library and all dependencies
- status [-f] Show the status for all your libraries
- commit <message> Commit to all repos with given message
- pull [<library>...] Pull the given or all repos
- push [<library>...] [--tags] Push the given or all repos
- checkout <branch> [<library>...] Change branch
- new-branch <branch> [<library>...] Creates a new branch(local and remote)
- rm-branch <branch> [<library>...] Removes branch(local and remote)
- diff Prints combined diff for all repos
- merge <branch> [<library>...] Merge in branch
- pack <library> [<library2>...] [my.h5p] Packs the given libraries
- increase-patch-version [<library>...] Increase the patch version
- tag-version [<library>...] Create a tag from the current version number
- create-language-file <library> <language-code> Creates language file
- import-language-files <from-dir> Get files from dir
We will take a closer look at each of the available commands in the following section.
h5p help <command>
If supplied a command, help will show a help message related to the usage of that command.
h5p help pack
Lists an overview of all H5P libraries registered with the cli. This command is especially helpful in combination with the other commands because it lists the library name which is required as a parameter for several other commands.
h5p get <library>
If supplied a library this command will get the library and all of its dependencies and make folders for each library that is fetched with their library name. If a folder with that library name already exists, it will be skipped.
h5p get h5p-summary
h5p status [-f]
This command shows the git status for every branch in current working directory. The -f handle can be used to display which branch each library is on.
h5p commit <message>
Commits to all repos in current working directory with the provided message.
h5p commit 'added norwegian translation to library'
h5p pull [<library>...]
Pulls all libraries in current working directory on their current branch. Given one or multiple libraries, separated by space, only the given ones will be pulled.
h5p pull h5p-summary
h5p push [<library>....] [--tags]
Pushes all repositories in working directory to their current branch. Given one or multiple libraries, separated by space, only the given ones will be pushed. By applying the --tags option, current tags associated with this commit will also be pushed.
h5p push h5p-summary --tags
h5p checkout <branch> [<library>...]
Given branch this command will checkout all repositories in current working directory that has this branch. If one or multiple libraries are given, only the given ones will be checked out.
h5p checkout master h5p-summary h5p-joubel-ui
h5p new-branch <branch> [<library>...]
If supplied with a branch this command will create the new branch both locally and remote if it does not exist. If multiple libraries are given, the new branch will be applied to all given libraries.
h5p new-branch my-new-branch h5p-summary h5p-joubel-ui
h5p rm-branch <branch> [<library>...]
If supplied with a branch this command will remove the specified branch both locally and remote if it exists. If multiple libraries are given, this action will be applied to all given libraries.
h5p rm-branch my-new-branch h5p-summary h5p-joubel-ui
Prints combined diff for all repositories in current working directory.
h5p merge <branch> [<library>...]
If supplied with a branch this command will merge the given branch into the current branch for all libraries where the given branch exists. If one or multiple libraries are given, this action will only be performed on these libraries.
h5p merge master
h5p pack <library> [<library2>...] [my.h5p]
If supplied with a library this command will pack target library into a .h5p file. Multiple libraries can be packed together by separating them by a space, which is highly recommended to get all dependencies a library depend on, packed together. A custom name for the H5P can be chosen by including the name as the last option. This name must end in .h5p
h5p pack h5p-summary h5p-joubel-ui my-awesome-libraries.h5p
h5p increase-patch-version [<library>...]
If one or multiple libraries are supplied this command will automatically increase the libraries' patch version.
h5p increase-patch-version h5p-summary h5p-joubel-ui
h5p tag-version [<library>...]
If supplied with one or multiple libraries these libraries are tagged with current version numbers.
h5p tag-version h5p-summary h5p-joubel-ui
h5p create-language-file <library> <language-code>
If supplied with a library and a language code this command will create a standardized language file with the given language code from semantics. "Language" folder must exist in the current working directory for this command to work properly.
h5p create-language-file h5p-summary nb
h5p import-language-files <from-dir>
If a directory is supplied, this command will get all language files from the given directory.
h5p import-language-files h5p-summary
Following is a short example showing some of the potential of the h5pcli. In this example we will:
- List all h5p libraries
- Get a specific library ("Multiple Choice")
- Check out a new branch ("branch")
- Merge master into this branch
- Add Norwegian translation
- Increase the patch version
- Tag the version
- Commit the new changes
- Push the new changes to the remote repository
A quite time-consuming process made super easy by the cli:
h5p list h5p get h5p-multi-choice h5p checkout branch h5p merge master h5p-multi-choice h5p create-language-file h5p-multichoice nb h5p increase-patch-version h5p-multichoice h5p tag-version h5p-multi-choice h5p status h5p commit 'added norwegian translation to multichoice' h5p push h5p-multi-choice
That's all! You are now ready to develop H5Ps with increased speed and focus on improving your content type, instead of tedious operations!
Fri, 06/03/2016 - 23:40
I would like to remind people
I would like to remind people: to install h5p cli will need run as administrator (both in windows and linux). Cheers.
Mon, 06/19/2017 - 21:20
What remote repository does this push to?
Tue, 06/20/2017 - 07:17
To the official github repository where a content type is stored (and where you, dear reader, probably don't have any access rights)
But if you are developing, you can clone a content type from Github, and use the cli on the cloned version. Or you can get a content type trough the cli, and change the remote origin.
Thu, 01/11/2018 - 01:54
Failed when try to clone
I have some issue when try to clone a library.Node is intalled,npm works fine,installed, h5p but whne i try to h5p get-dialogcards its allways return Failed(the cmd is raun as administrator) so i dont konw whats the reason why i could not clone a package,thank you for your help
Thu, 01/11/2018 - 09:06
Hi joopm,Do you have any
Do you have any specific error message/s that you are getting?
Thu, 01/11/2018 - 13:48
The command you should run is
The command you should run is:
Thu, 01/11/2018 - 14:32
Hello,thank you all your help
Hello,thank you all your help,this the error dialog
Thu, 01/11/2018 - 15:39
You GIT client is not
You GIT client is not configured correctly, which is required for the CLI to work. See readme in h5p-cli.
See git setup guide to get started with GIT, then when you think you have it working you can check with the following command:
Thu, 01/11/2018 - 19:55
Thank you for your help its help a lot.THe main problem was SSH was not set in Path and the rsa keys were not generated,i hope this will help for others
Fri, 01/12/2018 - 00:34
costumizing downloaded library
Thank you for your help now the downloading is working.
But there is no h5p.json file in the downloaded package,and if i try to zip the package and rename the extension name to h5p i get error after upload to moodle:
Validating h5p package failed.
What would be the error?
Fri, 01/12/2018 - 10:02
Hi, you must upload the
Hi, you must upload the packed library through the library list, not through the authoring tool since that expects there to be content within the .h5p file. We separate between two different .h5p files, .h5p file with libraries, and .h5p file with libraries and content.
To upload only libraries, upload the files through the library list.
Fri, 01/12/2018 - 14:41
Hello thomasmars,thank you
thank you for your help,yes you were right i tried to upload through authoring tool,just i was not aware about it(for me this name is not corresponding with the uploading h5p package).But if uploading modified content package is not through authoring tool why does Hello World uploaded correctly?
Fri, 01/12/2018 - 16:04
Hi,Since in the instructional
Since in the instructional "Hello World" tutorial you are creating the content as well, which is normally created by an author in the H5P editor (generically rendered from semantics.json). The steps to create the content of the H5P manually is explained in the "Hello world - manually create package" guide, this is not necessary when uploading H5P libraries through the library list.
Wed, 05/06/2020 - 15:43
H5P-FindTheWords not get listed in "h5p list"
"h5p list" does not list "H5P-FindTheWords"
How can I add "H5P-FindTheWords",
so its listed in "h5p list".
Mon, 03/06/2023 - 15:10
Command "h5p list" of h5p-cli does not return "image-pairing element" (https://h5p.org/image-pairing). Is this library supported at all?