MCPcopy
hub / github.com/smapiot/piral / beforeCommand

Function beforeCommand

src/tooling/piral-cli/src/api.ts:73–86  ·  view source on GitHub ↗
(commandName: string, before: ToolCommandRunner<U>)

Source from the content-addressed store, hash-verified

71}
72
73export function beforeCommand<U>(commandName: string, before: ToolCommandRunner<U>) {
74 if (typeof commandName !== 'string') {
75 log('apiCommandNameInvalid_0200', 'before command');
76 } else if (typeof before !== 'function') {
77 log('apiArgumentInvalid_0201', 'before', 'before command');
78 } else {
79 wrapCommand<U>(commandName, async (args, current) => {
80 await before(args);
81 await current(args);
82 });
83 }
84
85 return this;
86}
87
88export function afterCommand<U>(commandName: string, after: ToolCommandRunner<U>) {
89 if (typeof commandName !== 'string') {

Callers

nothing calls this directly

Calls 3

logFunction · 0.90
wrapCommandFunction · 0.85
currentFunction · 0.85

Tested by

no test coverage detected