MCPcopy Create free account
hub / github.com/apache/maka / parseAccessCommand

Function parseAccessCommand

packages/cli/src/runtime-host-cli.ts:431–555  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

429}
430
431function parseAccessCommand(argv: string[]): RuntimeHostCliCommand {
432 const action = argv[0];
433 if (action !== 'issue' && action !== 'revoke') {
434 return error(
435 action
436 ? `Unexpected runtime-host access command: ${action}`
437 : 'runtime-host access requires the issue or revoke command',
438 );
439 }
440 let rootPath: string | undefined;
441 let principalId: string | undefined;
442 let principalKind: 'remote_owner' | 'capability_provider' = 'remote_owner';
443 let principalKindSpecified = false;
444 let credentialId: string | undefined;
445 const operationGrants: string[] = [];
446 let canPublishClientCapabilities = false;
447 let canUseHostPaths = false;
448 let preset: 'desktop-client' | 'terminal-client' | undefined;
449 for (let index = 1; index < argv.length; index += 1) {
450 const argument = argv[index];
451 if (argument === '--publish-client-capabilities') {
452 canPublishClientCapabilities = true;
453 continue;
454 }
455 if (argument === '--allow-host-paths') {
456 canUseHostPaths = true;
457 continue;
458 }
459 if (
460 argument === '--root' ||
461 argument === '--kind' ||
462 argument === '--preset' ||
463 argument === '--principal' ||
464 argument === '--grant' ||
465 argument === '--credential'
466 ) {
467 const parsed = optionValue(argv, index, argument);
468 if (typeof parsed !== 'string') return parsed;
469 if (argument === '--root') rootPath = parsed;
470 if (argument === '--kind') {
471 if (parsed !== 'remote-owner' && parsed !== 'capability-provider') {
472 return error('--kind must be remote-owner or capability-provider');
473 }
474 principalKind = parsed === 'remote-owner' ? 'remote_owner' : 'capability_provider';
475 principalKindSpecified = true;
476 }
477 if (argument === '--preset') {
478 if (parsed !== 'desktop-client' && parsed !== 'terminal-client') {
479 return error('--preset must be desktop-client or terminal-client');
480 }
481 preset = parsed;
482 }
483 if (argument === '--principal') principalId = parsed;
484 if (argument === '--grant') operationGrants.push(parsed);
485 if (argument === '--credential') credentialId = parsed;
486 index += 1;
487 continue;
488 }

Callers 1

parseRuntimeHostCommandFunction · 0.85

Calls 3

errorFunction · 0.70
optionValueFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected