CREATE/CLI
P2LRN CLI
The CLI offers the same technical flows of the Toolkit from the terminal. Start with the usual route and then consult the specialized commands only when you need them.
1. Prerequisite
The CLI is installed with @p2lrn/toolkit. If you have not done so yet, complete first installation with NPM.
npm install @p2lrn/toolkit@0.5.0-alpha.11You can use the direct binaries —for example p2lrn-create— or the dispatcher p2lrn create.
2. Typical course creation workflow
These commands show the usual order: create workspace, add structure, add content, build and validate.
p2lrn-create init ./workspace --title "Digital safety course" --language en
p2lrn-create add-unit ./workspace \
--key unit-1 \
--title "Fundamentals"
p2lrn-create add-file ./workspace ./material/intro.html \
--key intro \
--title "Introduction" \
--parent unit-1
p2lrn-create build ./workspace ./course.p2lrn --strict-profiles
p2lrn-validate ./course.p2lrn --profile-payloadsa file curso.p2lrn valid. Then you can open it with Player or with him viewfinder.
3. Creation commands
init <dir> --title TCreate a new workspace. Supports language, description and --force.
open <package> <project_dir>Opens an existing package as an editable workspace.
upgrade <project>Updates the internal version of an existing workspace.
add-unitAdds a unit and allows you to indicate its parent, language and role.
add-fileAdds a local file and allows setting MIME type, profile, role and activity type.
add-web-contentAdd a web directory with its entrypoint.
add-urlAdd an external resource via URL.
add-questionnaireAdd a quiz. --renderer and --renderer-version select a preferred presentation.
add-component / add-compositeThey add structured native content and composite groups.
showShows a summary of the workspace.
build <project> <output>Build the final package; --strict-profiles requires complete profiles.
4. Validate, inspect and read a packet
Use these commands after the build to check the package, review its structure, or open it with Reader without modifying it.
p2lrn-validate ./course.p2lrn --profile-payloads
p2lrn-inspect ./course.p2lrn --summary --tree
p2lrn-reader ./course.p2lrn --summaryChecks structure, integrity and, with --profile-payloads, profile-specific data.
Shows summary, tree, reading plan, transformation or import depending on the chosen options.
Opens the interactive Reader or returns summary, tree, and plans without modifying the package.
5. Read a document
Use the document reader when you need to extract structure before deciding what content to convert into a course.
p2lrn-document-reader ./material/apuntes.docx --prettyExtract structure from DOCX, PPTX, ODT, EPUB and text formats. PDF required pdfjs-dist. The result is material for an authorship decision; it does not automatically convert to a full course.
6. Convert, repackage, and extract
p2lrn-convert <source> <output.p2lrn>Converts a supported font and can generate a report. p2lrn-wrap-external is an alias of the same converter for integrations that explicitly express external packaging.
p2lrn-repack <source> <output>Repackages without altering the logical content; you can generate a new package ID or canonicalize identifiers.
p2lrn-extract-source <package> <output.zip>Extract a preserved source and verify its SHA-256 before writing it.
7. Multipart
Use Multipart when a large resource must be published in verified parts rather than traveling entirely within the main file.
p2lrn-multipart ./course.p2lrn ./course-multipart.p2lrn \
--part-size 26214400Transforms an embedded representation into a descriptor and external parts. If you do not indicate --representation, selects the representation that exceeds the limit. Consultation Multipart for full flow.
8. Incremental changes (Delta)
Delta carries the difference between two compatible packages. Create the delta on a known basis and always apply it on that same basis.
p2lrn-delta create ./base.p2lrn ./new.p2lrn ./change.p2lrn-delta
p2lrn-delta apply ./base.p2lrn ./change.p2lrn-delta ./result.p2lrn
p2lrn-delta inspect ./change.p2lrn-deltacreate generates the difference, apply applies it on the correct basis and inspect shows its content.
9. Signing and trust
Trust signs and verifies packets with Ed25519. Signature is not a substitute for content integrity checks.
p2lrn-trust keygen ./private.pem ./public.pem
p2lrn-trust sign ./course.p2lrn ./private.pem --output ./course.sig
p2lrn-trust verify ./course.p2lrn ./course.sig --trust-key ./public.pem --require-trustedTrust manages separate Ed25519 signatures. Package integrity and trust in a signature are different checks.
10. Main command, output and return codes
The command p2lrn It also acts as a dispatcher for the main tools. Return codes allow them to be integrated into scripts and automatic processes.
p2lrn <validate|reader|document-reader|inspect|create|convert|repack|multipart|extract-source|delta|trust> ...
p2lrn --helpexit 0Correct operation or help requested.
exit 1Input, validation or execution error.
exit 2The main command p2lrn was executed without a valid subcommand.
Structured operations use JSON except for the interactive Reader and some textual inspection views.