Skip to content

@pumpkin-plugins/plugin-kit API / testing/fake-commands / FakeCommandHost

Class: FakeCommandHost ​

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:56

A CommandHost that builds FakeNodes and runs handlers by id, so tests can use a command tree without a server.

Implements ​

Methods ​

argument() ​

argument(spec): FakeNode

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:75

Creates a typed argument below a node.

Parameters ​

spec ​

CommandArgumentSpec

Returns ​

FakeNode

Implementation of ​

CommandHost.argument


fail() ​

fail(text): never

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:99

Makes the running command fail with a message, the way the server reports a failed command. Never returns.

Parameters ​

text ​

string

Returns ​

never

Implementation of ​

CommandHost.fail


hasPermission() ​

hasPermission(_sender, _permission): boolean

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:103

Checks whether a sender has a command permission.

Parameters ​

_sender ​

FakeSender

_permission ​

string

Returns ​

boolean

Implementation of ​

CommandHost.hasPermission


literal() ​

literal(name): FakeNode

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:71

Creates a fixed word below a node.

Parameters ​

name ​

string

Returns ​

FakeNode

Implementation of ​

CommandHost.literal


onRun() ​

onRun(run, _arguments): number

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:85

Registers what runs when a command is used, and returns its id.

Parameters ​

run ​

(sender, args) => void

_arguments ​

readonly CommandArgumentSpec[]

Returns ​

number

Implementation of ​

CommandHost.onRun


onSuggest() ​

onSuggest(handler): number

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:79

Registers a dynamic suggestion callback and returns its host handler ID.

Parameters ​

handler ​

CommandSuggestionHandler<FakeSender>

Returns ​

number

Implementation of ​

CommandHost.onSuggest


reply() ​

reply(sender, line, tone?): void

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:94

Sends a line back to whoever ran the command. An error line is shown in red.

Parameters ​

sender ​

FakeSender

line ​

string

tone? ​

"error"

Returns ​

void

Implementation of ​

CommandHost.reply


root() ​

root(name): FakeNode

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:67

Creates the root of a command: the word typed after /.

Parameters ​

name ​

string

Returns ​

FakeNode

Implementation of ​

CommandHost.root


run() ​

run(root, path, args?, sender?): string[]

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:118

Runs the command at the end of path (the words after /) and returns what it sent back.

Parameters ​

root ​

FakeNode

path ​

string[]

args? ​

Readonly<Record<string, CommandArgumentValue>> = {}

sender? ​

FakeSender

Returns ​

string[]


runAs() ​

runAs(root, path, args?, suppliedSender?): FakeSender

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:131

Runs the command at the end of path and returns the sender, to see which lines were errors.

Parameters ​

root ​

FakeNode

path ​

string[]

args? ​

Readonly<Record<string, CommandArgumentValue>> = {}

suppliedSender? ​

FakeSender

Returns ​

FakeSender

Throws ​

When the command failed.


suggest() ​

suggest(root, path, request): string[]

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:108

Resolves suggestions for an argument node through its registered callback.

Parameters ​

root ​

FakeNode

path ​

string[]

request ​

CommandSuggestionRequest

Returns ​

string[]


usages() ​

usages(root, prefix?): string[]

Defined in: tools/plugin-kit/src/testing/fake-commands.ts:147

The usages of every runnable node under root, such as /demo list.

Parameters ​

root ​

FakeNode

prefix? ​

string[] = ...

Returns ​

string[]

Pumpkin Plugins documentation