9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { ArgumentError } from '@jackwener/opencli/errors';
|
|
import { ensureApplet, ggbEval, requireGgbSuccess } from './utils.js';
|
|
|
|
cli({
|
|
site: 'geogebra',
|
|
name: 'eval',
|
|
access: 'write',
|
|
description: 'Execute one or more GeoGebra command strings (semicolon-separated)',
|
|
domain: 'www.geogebra.org',
|
|
strategy: Strategy.PUBLIC,
|
|
browser: true,
|
|
navigateBefore: false,
|
|
example: 'opencli geogebra eval "A=(0,0);B=(4,0);c=Circle(A,B);d=Circle(B,A);C=Intersect(c,d,1);Polygon(A,B,C)"',
|
|
args: [
|
|
{ name: 'command', positional: true, required: true, help: 'GeoGebra command string (use ; to chain multiple commands)' },
|
|
],
|
|
columns: ['command', 'result'],
|
|
func: async (page, kwargs) => {
|
|
const commands = String(kwargs.command).split(';').map(s => s.trim()).filter(Boolean);
|
|
if (commands.length === 0) {
|
|
throw new ArgumentError('command must contain at least one GeoGebra command');
|
|
}
|
|
await ensureApplet(page);
|
|
const results = [];
|
|
for (const command of commands) {
|
|
const result = requireGgbSuccess(await ggbEval(page, command), `Failed to execute GeoGebra command: ${command}`);
|
|
results.push({
|
|
command,
|
|
result: `ok (${result.label || 'no label'})`,
|
|
});
|
|
}
|
|
return results;
|
|
},
|
|
});
|