@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
Implementation of
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
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
_permission
string
Returns
boolean
Implementation of
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
Implementation of
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
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
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
line
string
tone?
"error"
Returns
void
Implementation of
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
Implementation of
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
path
string[]
args?
Readonly<Record<string, CommandArgumentValue>> = {}
sender?
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
path
string[]
args?
Readonly<Record<string, CommandArgumentValue>> = {}
suppliedSender?
Returns
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
path
string[]
request
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
prefix?
string[] = ...
Returns
string[]