1+ /**
2+ * Sift -- A flexible command parser for bricklib.
3+ * This plugin is part of the bricklib project.
4+ */
5+
6+ /* TODO: help-text gen, cmd builder, and more type parsers... */
7+
8+ import * as bricklib from '../bricklib/index.js' ;
19import { Player } from '@minecraft/server' ;
2- import { CommandCallback , CommandManager } from '../command.js' ;
310import { parseVerb } from './parser.js' ;
411import { ArgTokenStream } from './tokens.js' ;
512import type { CmdVerb , ParseResult } from './defs.ts' ;
613
14+
715export type * from './defs.ts' ;
816export * from './parser.js' ;
917export * from './tokens.js' ;
1018export * as parsers from './types.js' ;
1119
20+ bricklib . plugin . newPlugin ( 'sift' , ( ) => {
21+ /* no-op */
22+ } ) ;
23+
24+
1225/**
1326 * Parse a custom command.
1427 * @param def The command parsing definition.
@@ -25,25 +38,25 @@ export function parseCommand(def: CmdVerb, args: string[]): ParseResult
2538
2639/**
2740 * Make a command def that you can pass to
28- * {@link CommandManager.registerCommand}.
41+ * {@link bricklib.command. CommandManager.registerCommand}.
2942 * @param def The command definition.
3043 * @param fn The callback.
3144 * @returns Array of args.
3245 * @example
3346 * ```ts
34- * import * as bricklib from './bricklib /index.js';
47+ * import * as sift from './sift /index.js';
3548 * const def = {
3649 * id: 'echo',
3750 * name: 'echo',
3851 * args: [
3952 * {
4053 * id: 'text',
41- * type: bricklib.args .parsers.string(),
54+ * type: sift .parsers.string(),
4255 * }
4356 * ]
4457 * };
4558 *
46- * mgr.registerCommand(...bricklib.args .makeCommand(def, (args, src) => {
59+ * mgr.registerCommand(...sift .makeCommand(def, (args, src) => {
4760 * src.sendMessage(args.text);
4861 * return 0;
4962 * }));
@@ -52,9 +65,9 @@ export function parseCommand(def: CmdVerb, args: string[]): ParseResult
5265export function makeCommand < T = any > (
5366 def : CmdVerb ,
5467 fn : ( args : ParseResult < T > , src : Player ) => number
55- ) : [ string [ ] , CommandCallback ]
68+ ) : [ string [ ] , bricklib . command . CommandCallback ]
5669{
57- const out : [ string [ ] , CommandCallback ] = [ null , null ] ;
70+ const out : [ string [ ] , bricklib . command . CommandCallback ] = [ null , null ] ;
5871 out [ 0 ] = [ def . name ] ;
5972 if ( def . aliases )
6073 out [ 0 ] = out [ 0 ] . concat ( def . aliases ) ;
0 commit comments