Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ae2f54e
feat(commands): extend defineCommand for the CLI's own commands
edusperoni Sep 14, 2026
e4bf7da
refactor(commands): migrate every command to defineCommand
edusperoni Sep 14, 2026
13db77e
feat(commands): register commands lazily against a checked definition…
edusperoni Sep 14, 2026
70ff020
feat(commands)!: dispatch in process, rename ctx.arguments to ctx.params
edusperoni Sep 14, 2026
83381c5
feat(key-shortcuts): declarative table with a generic engine
edusperoni Sep 14, 2026
6d8cc6e
feat(key-shortcuts): registry contract and command-declared shortcuts
edusperoni Sep 14, 2026
53551c7
fix(bundler): tear the bundler down before starting another one
edusperoni Sep 14, 2026
2b1ee61
feat(key-shortcuts): r/R/B restart ladder, hint reprint, session scoping
edusperoni Sep 14, 2026
217a38b
feat(commands): a class form built on defineCommand
edusperoni Sep 14, 2026
3361798
refactor(commands): one context per invocation and the class-form sweep
edusperoni Sep 14, 2026
693e34d
feat(commands): the in-process dispatcher as a contract
edusperoni Sep 14, 2026
d987e0b
refactor(commands): fail through the context and read options from it
edusperoni Sep 23, 2026
d7de648
feat(commands): definition providers, multi providers and preconditions
edusperoni Sep 23, 2026
b41cadd
fix(commands): close the review gaps in the command API
edusperoni Sep 23, 2026
3549b4c
refactor(commands): drop what never shipped and the leftovers the rev…
edusperoni Sep 23, 2026
ffa6afa
chore: leave declarations.d.ts untouched
edusperoni Sep 23, 2026
145c39f
fix: address the first review round on the command API and shortcuts
edusperoni Sep 23, 2026
61f4997
feat(commands)!: declare positional parameters as `params`, options a…
edusperoni Sep 23, 2026
72de270
feat(commands): option groups, invocation scopes and the invocation r…
edusperoni Sep 23, 2026
75009b0
docs(commands): option groups, process-level options, scopes and the …
edusperoni Sep 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,132 changes: 1,064 additions & 68 deletions defining-commands.md

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const { defineCommand, inject } = require("nativescript/contracts");

module.exports = defineCommand({
name: "hello|world",
arguments: "any",
params: "any",
async run(ctx) {
inject("logger").info(`Hello, ${ctx.args[0] || "world"}!`);
},
Expand All @@ -205,6 +205,23 @@ the command itself, executing that command fails with an error naming the
extension, the command and the module — the entry points at the wrong file, or
the file is not doing what the entry promises.

Options and option groups
-------------------------

An extension's own commands declare options exactly as built-in commands do,
option groups included. `defineOptions`, `CliOptions` and the option helpers
are exported from `"nativescript/contracts"`, and a group a command lists under
`options` is parsed with it and can be injected by services in its invocation
(see [defining-commands.md](defining-commands.md#option-groups)).

Adding options to a command the extension does not own, or to the
process-level options, is not supported for a manifest-declared extension yet.
The `OptionContributions` contract exists as a programmatic seam, and code
whose module is loaded before the target parse can call it. A command module
named in the manifest is loaded only when its own command is resolved, so it
cannot add options to a built-in command the user invoked. A manifest-level
way to declare a contribution does not exist yet.

Command names
-------------

Expand All @@ -218,7 +235,7 @@ rejected with a warning.
**The manifest key decides how a command is invoked.** It has to: the CLI routes
`ns hello world` to your module before that module has been loaded, so the key
is the only name it can know. A `name` inside the definition is metadata — it is
what `registerCommandDefinition` uses when a module registers itself, and it is
what `registerCommand` uses when a module registers itself, and it is
useful documentation, but a manifest entry overrides it. If the two disagree the
CLI warns, naming both, and runs the command under the manifest key.

Expand Down
Loading
Loading