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

Function wrapCommand

src/tooling/piral-cli/src/api.ts:58–71  ·  view source on GitHub ↗
(commandName: string, wrapper: ToolCommandWrapper<U>)

Source from the content-addressed store, hash-verified

56}
57
58export function wrapCommand<U>(commandName: string, wrapper: ToolCommandWrapper<U>) {
59 if (typeof commandName !== 'string') {
60 log('apiCommandNameInvalid_0200', 'command');
61 } else if (typeof wrapper !== 'function') {
62 log('apiArgumentInvalid_0201', 'wrapper', 'command');
63 } else {
64 findAll(commandName, (command) => {
65 const current = command.run;
66 command.run = (args) => wrapper(args, current);
67 });
68 }
69
70 return this;
71}
72
73export function beforeCommand<U>(commandName: string, before: ToolCommandRunner<U>) {
74 if (typeof commandName !== 'string') {

Callers 2

beforeCommandFunction · 0.85
afterCommandFunction · 0.85

Calls 3

logFunction · 0.90
findAllFunction · 0.85
wrapperFunction · 0.85

Tested by

no test coverage detected