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
28 lines
1008 B
JavaScript
28 lines
1008 B
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { ensureApplet, ggbEval, normalizeCoords, normalizeLabel, requireGgbSuccess } from './utils.js';
|
|
|
|
cli({
|
|
site: 'geogebra',
|
|
name: 'add-point',
|
|
access: 'write',
|
|
description: 'Create a point with given label and coordinates',
|
|
domain: 'www.geogebra.org',
|
|
strategy: Strategy.PUBLIC,
|
|
browser: true,
|
|
navigateBefore: false,
|
|
example: 'opencli geogebra add-point --name A --coords 1,2',
|
|
args: [
|
|
{ name: 'name', required: true, help: 'Point label (e.g. A, B, P1)' },
|
|
{ name: 'coords', required: true, help: 'Coordinates as x,y (e.g. "1,2")' },
|
|
],
|
|
columns: ['name', 'x', 'y'],
|
|
func: async (page, kwargs) => {
|
|
const name = normalizeLabel(kwargs.name, 'name');
|
|
const [x, y] = normalizeCoords(kwargs.coords);
|
|
const cmd = `${name}=(${x},${y})`;
|
|
await ensureApplet(page);
|
|
const result = requireGgbSuccess(await ggbEval(page, cmd), `Failed to create point: ${cmd}`);
|
|
return [{ name, x, y }];
|
|
},
|
|
});
|