| 1 | // The presets in this file contain lists of props that are considered as updated |
| 2 | // automatically between a older spec and a new one, so every prop from the new one |
| 3 | // can override the one of the old one. All the props not contained here are overridden |
| 4 | // if and only if they are not present in the new spec at the same location |
| 5 | |
| 6 | export type Preset = { |
| 7 | commandProps: Set<string>; |
| 8 | optionProps: Set<string>; |
| 9 | argProps: Set<string>; |
| 10 | }; |
| 11 | |
| 12 | export function defaultPreset(): Preset { |
| 13 | return { |
| 14 | commandProps: new Set(["name", "description", "args", "subcommands", "options"]), |
| 15 | optionProps: new Set(["name", "description", "args"]), |
| 16 | argProps: new Set(["name", "description"]), |
| 17 | }; |
| 18 | } |
| 19 | |
| 20 | export type PresetName = |
| 21 | | "commander" |
| 22 | | "oclif" |
| 23 | | "cobra" |
| 24 | | "clap" |
| 25 | | "swift-argument-parser" |
| 26 | | "click" |
| 27 | | "cement" |
| 28 | | "argparse"; |
| 29 | |
| 30 | const argparsePreset = { |
| 31 | commandProps: new Set(["name", "subcommands", "options", "args", "hidden", "description"]), |
| 32 | optionProps: new Set(["name", "hidden", "description", "isRepeatable", "args", "isRequired"]), |
| 33 | argProps: new Set(["name", "isVariadic", "isOptional", "hidden", "description", "suggestion"]), |
| 34 | }; |
| 35 | |
| 36 | export const presets: Record<PresetName, Preset> = { |
| 37 | commander: { |
| 38 | commandProps: new Set(["name", "description", "subcommands", "options", "args", "hidden"]), |
| 39 | optionProps: new Set(["name", "description", "isRequired", "args"]), |
| 40 | argProps: new Set([ |
| 41 | "name", |
| 42 | "description", |
| 43 | "isOptional", |
| 44 | "isVariadic", |
| 45 | "suggestions", |
| 46 | "default", |
| 47 | ]), |
| 48 | }, |
| 49 | oclif: { |
| 50 | commandProps: new Set(["name", "description", "subcommands", "options", "args"]), |
| 51 | optionProps: new Set(["name", "description", "isRequired", "args", "exclusiveOn"]), |
| 52 | argProps: new Set(["name", "description", "isOptional", "suggestions", "default"]), |
| 53 | }, |
| 54 | cobra: { |
| 55 | commandProps: new Set(["name", "description", "subcommands", "options", "args"]), |
| 56 | optionProps: new Set([ |
| 57 | "name", |
| 58 | "description", |
| 59 | "displayName", |
| 60 | "isRepeatable", |
| 61 | "isRequired", |
| 62 | "args", |
| 63 | ]), |
| 64 | argProps: new Set(["name", "description", "template", "default"]), |
| 65 | }, |
| 66 | clap: { |
| 67 | commandProps: new Set(["name", "description", "subcommands", "options", "args", "hidden"]), |
| 68 | optionProps: new Set([ |
| 69 | "name", |
| 70 | "description", |
| 71 | "args", |
| 72 | "isRepeatable", |
| 73 | "exclusiveOn", |
| 74 | "hidden", |
| 75 | "requiresEquals", |
| 76 | ]), |
| 77 | argProps: new Set(["name", "isVariadic", "isOptional", "suggestions", "template", "isCommand"]), |
| 78 | }, |
| 79 | "swift-argument-parser": { |
| 80 | commandProps: new Set(["name", "description", "subcommands", "options", "args"]), |
| 81 | optionProps: new Set(["name", "isRequired", "isRepeatable", "description", "hidden"]), |
| 82 | argProps: new Set(["name", "description", "default", "isVariadic", "isOptional"]), |
| 83 | }, |
| 84 | click: { |
| 85 | commandProps: new Set([ |
| 86 | "name", |
| 87 | "description", |
| 88 | "options", |
| 89 | "subcommands", |
| 90 | "args", |
| 91 | "hidden", |
| 92 | "deprecated", |
| 93 | ]), |
| 94 | optionProps: new Set([ |
| 95 | "name", |
| 96 | "description", |
| 97 | "isRepeatable", |
| 98 | "isRequired", |
| 99 | "exclusiveOn", |
| 100 | "args", |
| 101 | ]), |
| 102 | argProps: new Set(["name", "suggestions", "template", "suggestCurrentToken", "isVariadic"]), |
| 103 | }, |
| 104 | argparse: argparsePreset, |
| 105 | cement: argparsePreset, |
| 106 | }; |