xpm init
Purpose
Initialise a new project.
Synopsis
xpm init [options...] [--template <xpack>] [--name <string>]
[--property <string>]*
Aliases:
ini
Description
Initialise the current folder as an xpm package by creating a skeleton
package.json
file. This file requires further editing to update most
of the objects.
If invoked with a template, use the template to create a custom project with as many files and folders as necessary.
The current behaviour may change, as the template API is not yet final.
Options
Help (--help
)
% xpm init --help
xPack project manager - create an xpm package, empty or from a template
Usage: xpm init [options...] [--template <xpack>] [--name <string>]
[--property <string>]* [--ignore-errors]
Init options:
-t|--template <xpack> The xpm package implementing the template (optional)
-n|--name <string> Project name (optional)
-p|--property <string> Substitution variables (optional, multiple)
--ignore-errors Ignore script errors (optional)
Common options:
--loglevel <level> Set log level (silent|warn|info|verbose|debug|trace)
-s|--silent Disable all messages (--loglevel silent)
-q|--quiet Mostly quiet, warnings and errors (--loglevel warn)
--informative Informative (--loglevel info)
-v|--verbose Verbose (--loglevel verbose)
-d|--debug Debug messages (--loglevel debug)
-dd|--trace Trace messages (--loglevel trace, -d -d)
--no-update-notifier Skip check for a more recent version
-C <folder> Set current folder
xpm -h|--help Quick help
xpm --version Show version
xpm -i|--interactive Enter interactive mode
npm xpm@0.20.8 '/Users/ilg/.nvm/versions/node/v20.18.0/lib/node_modules/xpm'
Home page: <https://xpack.github.io/xpm-preview/>
Bug reports: <https://github.com/xpack/xpm-js/issues>
Template (-t|--template <xpack>
)
Create the xpm package using a template. The template itself is an xpm package containing a specific code that implements the template API.
Name (--name <string>
)
Define a name for the new xpm package. If omitted, the package name is derived from the current folder name.
Properties (-p|--property <string>
)
Pass pairs of name=value
properties to the template engine. Multiple
properties can be defined.
The names, values and behaviours are all specific to each template engine.
Examples
Interactive session
Create a project in an interactive session by answering several questions:
% mkdir my-project && cd my-project
% xpm init --template @xpack/hello-world-template@latest
Checking package @xpack/hello-world-template@latest metadata...
Processing @xpack/hello-world-template@0.6.1...
Programming language? (c, cpp, ?) [cpp]: c
Build System? (cmake, meson, autotools, ?) [cmake]:
Toolchain? (gcc, clang, system, ?) [gcc]: clang
Creating the C project 'my-project'...
File 'include/hello-world.h' copied.
File 'src/hello-world.c' copied.
File 'libs/adder/include/add/add.h' copied.
File 'libs/adder/src/add.c' copied.
Folder 'cmake' copied.
File 'CMakeLists.txt' generated.
File '.vscode/tasks.json' copied.
File '.vscode/settings.json' copied.
File '.gitignore' copied.
File '.npmignore' copied.
File 'README.md' generated.
File 'LICENSE' generated.
File 'package.json' generated.
Scriptable session
The same template as before, if it receives a mandatory
language
property,
can create the project without further questions by using defaults:
% mkdir -p my-project && cd my-project
% xpm init --template @xpack/hello-world-template@latest --property language=c --property toolchain=clang
Installing @xpack/hello-world-template@0.6.1...
Processing @xpack/hello-world-template@0.6.1...
Creating the C project 'my-project'...
- buildGenerator=cmake
- toolchain=clang
File 'include/hello-world.h' copied.
File 'src/hello-world.c' copied.
File 'libs/adder/include/add/add.h' copied.
File 'libs/adder/src/add.c' copied.
Folder 'cmake' copied.
File 'CMakeLists.txt' generated.
File '.vscode/tasks.json' copied.
File '.vscode/settings.json' copied.
File '.gitignore' copied.
File '.npmignore' copied.
File 'README.md' generated.
File 'LICENSE' generated.
File 'package.json' generated.