MCPcopy Create free account
hub / github.com/EvoMap/evolver / parseReuseArgs

Function parseReuseArgs

src/gep/cliContracts.js:220–245  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

218}
219
220function parseReuseArgs(args) {
221 let id = null;
222 let jsonOut = false;
223 for (let i = 0; i < args.length; i++) {
224 const token = args[i];
225 if (!token) continue;
226 if (token === '--json') { jsonOut = true; continue; }
227 if (token === '--id') {
228 const next = args[i + 1];
229 if (!next || String(next).startsWith('--')) return { ok: false, reason: 'missing_id', message: 'reuse requires --id <asset_id>' };
230 id = String(next).trim();
231 i++;
232 continue;
233 }
234 if (typeof token === 'string' && token.startsWith('--id=')) {
235 id = token.slice('--id='.length).trim();
236 continue;
237 }
238 if (String(token).startsWith('--')) return { ok: false, reason: 'unsupported', message: 'unsupported reuse flag' };
239 return { ok: false, reason: 'unsupported', message: 'unsupported reuse argument' };
240 }
241 if (!jsonOut) return { ok: false, reason: 'unsupported', message: 'reuse requires --json' };
242 if (!id) return { ok: false, reason: 'missing_id', message: 'reuse requires --id <asset_id>' };
243 if (id.length > 200) return { ok: false, reason: 'missing_id', message: 'asset id must be <= 200 characters' };
244 return { ok: true, assetId: id, jsonOut };
245}
246
247function parsePublishArgs(args) {
248 const assetRefs = [];

Callers 2

runReuseCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected