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.

Terminal
npm install @p2lrn/toolkit@0.5.0-alpha.11

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

Terminal
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-payloads
What you should get.

a file curso.p2lrn valid. Then you can open it with Player or with him viewfinder.

3. Creation commands

init <dir> --title T

Create 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-unit

Adds a unit and allows you to indicate its parent, language and role.

add-file

Adds a local file and allows setting MIME type, profile, role and activity type.

add-web-content

Add a web directory with its entrypoint.

add-url

Add an external resource via URL.

add-questionnaire

Add a quiz. --renderer and --renderer-version select a preferred presentation.

add-component / add-composite

They add structured native content and composite groups.

show

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

Terminal
p2lrn-validate ./course.p2lrn --profile-payloads
p2lrn-inspect ./course.p2lrn --summary --tree
p2lrn-reader ./course.p2lrn --summary
validate

Checks structure, integrity and, with --profile-payloads, profile-specific data.

inspect

Shows summary, tree, reading plan, transformation or import depending on the chosen options.

reader

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.

Terminal
p2lrn-document-reader ./material/apuntes.docx --pretty

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

Terminal
p2lrn-multipart ./course.p2lrn ./course-multipart.p2lrn \
  --part-size 26214400

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

Terminal
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-delta

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

Terminal
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-trusted

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

Terminal
p2lrn <validate|reader|document-reader|inspect|create|convert|repack|multipart|extract-source|delta|trust> ...
p2lrn --help
exit 0

Correct operation or help requested.

exit 1

Input, validation or execution error.

exit 2

The main command p2lrn was executed without a valid subcommand.

Salida

Structured operations use JSON except for the interactive Reader and some textual inspection views.