xPulse
πŸ‡¬πŸ‡§ EN

Guide

Installation

@xpulse/cli is installed locally in the project – no global install needed.

npm install @xpulse/cli

Important: The project's package.json must include "type": "module", as the entire xPulse ecosystem uses ESM (import/export):

{
"name": "my-project",
"type": "module",
"dependencies": {
"@xpulse/cli": "^1.0.0"
}
}

Usage – always with `npx`

@xpulse/cli is always called via npx. This uses the local version from node_modules/.bin/xpulse – consistent, reproducible, no version mismatch with globally installed versions.

npx xpulse --version
npx xpulse --list
npx xpulse --help
npx xpulse --help tapp:hello
npx xpulse tapp:hello --help
npx xpulse tapp:hello Johnny -lang="en" --shout

How does it work?

@xpulse/cli starts and automatically discovers all Command classes:

npx xpulse doc:fetch chat --dry-run
↓
@xpulse/cli discovers:
1. node_modules/@xpulse/*/src/commands/*.js ← installed xParts
2. src/commands/*.js ← local project
β†’ finds FetchCommand (name = 'doc:fetch')
β†’ builds Input + Output, injects keepAlive
β†’ new FetchCommand().run(input, output)
↓
FetchCommand.run() executes β†’ return 0
↓
@xpulse/cli β†’ process.exit(0)

Writing a command

Create a file under src/commands/, extend Command – done. @xpulse/cli finds it automatically.

// src/commands/HelloCommand.js
import { Command } from '@xpulse/cli/command';
export class HelloCommand extends Command {
configure() {
this
.setName('tapp:hello')
.setAlias('hi')
.setDescription('Say hello')
.setHelp('Prints a greeting message to the console.')
.addArgument('name', 'Anon', 'Name of the recipient')
.addOption('lang', 'de', 'Language (de/en)')
.addFlag('shout', false, 'Output in uppercase');
}
async run(input, output) {
const name = input.getArgument('name');
const shout = input.getFlag('shout');
let msg = `Hello ${name}!`;
if (shout) msg = msg.toUpperCase();
output.success(msg);
return 0;
}
}

No import event, no cli:done – just return an exit code.

Argument vs. Option vs. Flag

Type Definition Usage
Argument addArgument('name', ...) npx xpulse cmd Johnny (positional)
Option addOption('lang', ...) npx xpulse cmd -lang="en"
Flag addFlag('shout', ...) npx xpulse cmd --shout

Important: Options must always use =:

npx xpulse tapp:hello -lang="en" # βœ“ correct
npx xpulse tapp:hello --lang="en" # βœ“ correct
npx xpulse tapp:hello -lang en # βœ— warning – "en" treated as positional argument
npx xpulse tapp:hello --lang en # βœ— warning – "en" treated as positional argument

When using incorrect syntax, @xpulse/cli outputs a warning:

! Invalid syntax: "--lang en" – did you mean --lang="en"?
"en" is treated as a positional argument.

Exit codes

Code Meaning
0 Success
1 Error
2 Misuse – wrong or missing arguments

Long-running commands

Commands that run longer than CLI_TIMEOUT (default: 30s) call this.keepAlive() periodically to reset the timeout:

async run(input, output) {
while (!done) {
await doWork();
this.keepAlive(); // reset timeout – no event import needed
}
return 0;
}

Configure timeout

CLI_TIMEOUT=60 npx xpulse repo:changelog:generate
en/guide.md 2026-03-16