mirror of https://github.com/garrytan/gstack.git
feat(browse): accept screenshot --clip=x,y,w,h (equals-sign syntax)
Currently \`screenshot --clip\` only accepts the space-separated form:
browse screenshot --clip 100,200,300,400 out.png
GNU long-option convention also supports the \`--flag=value\` form, which is
handy when generating commands programmatically (no need to track whether
the next argv element is the value or another flag) and matches what most
CLI users expect. After this change, both work:
browse screenshot --clip 100,200,300,400 out.png # existing, unchanged
browse screenshot --clip=100,200,300,400 out.png # new
Two-line change in the option parser. Existing space-separated callers and
the error message ("Usage: screenshot --clip x,y,w,h [path]") are
unchanged. Other flags in this handler (--viewport, --selector, --base64)
keep their current single-form parsing — if folks want \`--viewport=\` etc.
that's a worthwhile follow-up but feels out of scope for a one-flag patch.
This commit is contained in:
parent
026751ea20
commit
d93c521b94
|
|
@ -442,8 +442,8 @@ export async function handleMetaCommand(
|
|||
} else if (args[i] === '--selector') {
|
||||
flagSelector = args[++i];
|
||||
if (!flagSelector) throw new Error('Usage: screenshot --selector <css> [path]');
|
||||
} else if (args[i] === '--clip') {
|
||||
const coords = args[++i];
|
||||
} else if (args[i] === '--clip' || args[i].startsWith('--clip=')) {
|
||||
const coords = args[i] === '--clip' ? args[++i] : args[i].slice('--clip='.length);
|
||||
if (!coords) throw new Error('Usage: screenshot --clip x,y,w,h [path]');
|
||||
const parts = coords.split(',').map(Number);
|
||||
if (parts.length !== 4 || parts.some(isNaN))
|
||||
|
|
|
|||
Loading…
Reference in New Issue