-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make some of the optional flags required #829
Comments
@bader-nasser Does using either the If those don't get you what you need I'd recommend sticking with your current solution or submitting a PR for the feature yourself since I'm not sure we'd be able to prioritize this feature at the moment. |
@mdonnalley No. I use firstPage: Flags.string({
char: 'f',
description: 'First page (defaults to lastPage)',
// This flag cannot be specified alongside these other flags
exclusive: ['pageRanges', 'data'],
}),
lastPage: Flags.string({
char: 'l',
description: 'Last page (defaults to firstPage)',
// This flag cannot be specified alongside these other flags
exclusive: ['pageRanges', 'data'],
}),
pageRanges: Flags.string({
char: 'p',
description: `Comma/Space-seperated list of page ranges (eg. "1-3, 5east, 4, 7-10even, 22-11odd")
See: https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-cat
See also: https://github.com/bader-nasser/pdftools/blob/main/test/docs/data.txt`,
// This flag cannot be specified alongside these other flags
exclusive: ['firstPage', 'lastPage', 'data'],
}),
data: Flags.string({
char: 'd',
description: `Data file (lines of page ranges)
See: https://github.com/bader-nasser/pdftools/blob/main/test/docs/data.txt`,
// This flag cannot be specified alongside these other flags
exclusive: ['firstPage', 'lastPage', 'pageRanges'],
}),
qualifier: Flags.string({
char: 'q',
options: ['even', 'odd'],
description:
'See: https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-cat',
relationships: [
// Make this flag dependent on at least one of these flags
{type: 'some', flags: ['firstPage', 'lastPage']},
// Make this flag exclusive of all these flags
{type: 'none', flags: ['pageRanges', 'data']},
],
}),
rotation: Flags.string({
char: 'r',
options: ['north', 'south', 'east', 'west', 'left', 'right', 'down'],
description:
'See: https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-cat',
relationships: [
// Make this flag dependent on at least one of these flags
{type: 'some', flags: ['firstPage', 'lastPage']},
// Make this flag exclusive of all these flags
{type: 'none', flags: ['pageRanges', 'data']},
],
}), The current flags' configuration is great but I don't see a way to make some these flags required. I'll stick with my solution and I'm not sure about sending a PR for the time being. |
This issue has been linked to a new work item: W-15187594 |
Is your feature request related to a problem? Please describe.
I have many optional flags, but I want at least one of these to be required.
https://github.com/bader-nasser/pdftools#pdftools-extract:
I want to set one of flags:
-f
,-l
,-p
or-d
to be required. By the way,[-l <value> | | ]
seems like a bug to me because I think it should look like[-l <value> | -p <value> | -d <value>]
but I'm not sure!Describe the solution you'd like
Maybe using a static property like:
Describe alternatives you've considered
I tried to use
if
statements to make sure one of these flags is provided by the user!The text was updated successfully, but these errors were encountered: