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

Function withFlags

src/tooling/piral-cli/src/api.ts:43–56  ·  view source on GitHub ↗
(commandName: string, setter: ToolCommandFlagsSetter<T>)

Source from the content-addressed store, hash-verified

41}
42
43export function withFlags<T>(commandName: string, setter: ToolCommandFlagsSetter<T>) {
44 if (typeof commandName !== 'string') {
45 log('apiCommandNameInvalid_0200', 'flags');
46 } else if (typeof setter !== 'function') {
47 log('apiArgumentInvalid_0201', 'setter', 'flags');
48 } else {
49 findAll(commandName, (command) => {
50 const current = command.flags || ((x) => x);
51 command.flags = (argv) => current(setter(argv));
52 });
53 }
54
55 return this;
56}
57
58export function wrapCommand<U>(commandName: string, wrapper: ToolCommandWrapper<U>) {
59 if (typeof commandName !== 'string') {

Callers 1

maybeWithFlagsFunction · 0.85

Calls 3

logFunction · 0.90
findAllFunction · 0.85
currentFunction · 0.85

Tested by

no test coverage detected