@villedemontreal/caporal 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/src/__tests__/issue-163.spec.d.ts +2 -0
- package/dist/src/__tests__/issue-163.spec.d.ts.map +1 -0
- package/dist/src/__tests__/issue-163.spec.js +17 -0
- package/dist/src/__tests__/issue-163.spec.js.map +1 -0
- package/dist/src/argument/__tests__/argument.spec.d.ts +2 -0
- package/dist/src/argument/__tests__/argument.spec.d.ts.map +1 -0
- package/dist/src/argument/__tests__/argument.spec.js +85 -0
- package/dist/src/argument/__tests__/argument.spec.js.map +1 -0
- package/dist/src/argument/find.d.ts +8 -0
- package/dist/src/argument/find.d.ts.map +1 -0
- package/dist/src/argument/find.js +11 -0
- package/dist/src/argument/find.js.map +1 -0
- package/dist/src/argument/index.d.ts +13 -0
- package/dist/src/argument/index.d.ts.map +1 -0
- package/dist/src/argument/index.js +27 -0
- package/dist/src/argument/index.js.map +1 -0
- package/dist/src/argument/synopsis.d.ts +19 -0
- package/dist/src/argument/synopsis.d.ts.map +1 -0
- package/dist/src/argument/synopsis.js +39 -0
- package/dist/src/argument/synopsis.js.map +1 -0
- package/dist/src/argument/validate.d.ts +43 -0
- package/dist/src/argument/validate.d.ts.map +1 -0
- package/dist/src/argument/validate.js +127 -0
- package/dist/src/argument/validate.js.map +1 -0
- package/dist/src/autocomplete/__fixtures__/prog-autocomplete.d.ts +3 -0
- package/dist/src/autocomplete/__fixtures__/prog-autocomplete.d.ts.map +1 -0
- package/dist/src/autocomplete/__fixtures__/prog-autocomplete.js +24 -0
- package/dist/src/autocomplete/__fixtures__/prog-autocomplete.js.map +1 -0
- package/dist/src/autocomplete/__tests__/autocomplete.spec.d.ts +2 -0
- package/dist/src/autocomplete/__tests__/autocomplete.spec.d.ts.map +1 -0
- package/dist/src/autocomplete/__tests__/autocomplete.spec.js +119 -0
- package/dist/src/autocomplete/__tests__/autocomplete.spec.js.map +1 -0
- package/dist/src/autocomplete/index.d.ts +20 -0
- package/dist/src/autocomplete/index.d.ts.map +1 -0
- package/dist/src/autocomplete/index.js +172 -0
- package/dist/src/autocomplete/index.js.map +1 -0
- package/dist/src/autocomplete/types.d.ts +26 -0
- package/dist/src/autocomplete/types.d.ts.map +1 -0
- package/dist/src/autocomplete/types.js +3 -0
- package/dist/src/autocomplete/types.js.map +1 -0
- package/dist/src/command/__fixtures__/example-cmd.d.ts +8 -0
- package/dist/src/command/__fixtures__/example-cmd.d.ts.map +1 -0
- package/dist/src/command/__fixtures__/example-cmd.js +10 -0
- package/dist/src/command/__fixtures__/example-cmd.js.map +1 -0
- package/dist/src/command/__tests__/command.spec.d.ts +2 -0
- package/dist/src/command/__tests__/command.spec.d.ts.map +1 -0
- package/dist/src/command/__tests__/command.spec.js +510 -0
- package/dist/src/command/__tests__/command.spec.js.map +1 -0
- package/dist/src/command/__tests__/find.spec.d.ts +2 -0
- package/dist/src/command/__tests__/find.spec.d.ts.map +1 -0
- package/dist/src/command/__tests__/find.spec.js +31 -0
- package/dist/src/command/__tests__/find.spec.js.map +1 -0
- package/dist/src/command/__tests__/import.spec.d.ts +2 -0
- package/dist/src/command/__tests__/import.spec.d.ts.map +1 -0
- package/dist/src/command/__tests__/import.spec.js +17 -0
- package/dist/src/command/__tests__/import.spec.js.map +1 -0
- package/dist/src/command/__tests__/scan.spec.d.ts +2 -0
- package/dist/src/command/__tests__/scan.spec.d.ts.map +1 -0
- package/dist/src/command/__tests__/scan.spec.js +20 -0
- package/dist/src/command/__tests__/scan.spec.js.map +1 -0
- package/dist/src/command/find.d.ts +8 -0
- package/dist/src/command/find.d.ts.map +1 -0
- package/dist/src/command/find.js +47 -0
- package/dist/src/command/find.js.map +1 -0
- package/dist/src/command/import.d.ts +7 -0
- package/dist/src/command/import.d.ts.map +1 -0
- package/dist/src/command/import.js +47 -0
- package/dist/src/command/import.js.map +1 -0
- package/dist/src/command/index.d.ts +211 -0
- package/dist/src/command/index.d.ts.map +1 -0
- package/dist/src/command/index.js +374 -0
- package/dist/src/command/index.js.map +1 -0
- package/dist/src/command/scan.d.ts +4 -0
- package/dist/src/command/scan.d.ts.map +1 -0
- package/dist/src/command/scan.js +31 -0
- package/dist/src/command/scan.js.map +1 -0
- package/dist/src/command/validate-call.d.ts +8 -0
- package/dist/src/command/validate-call.d.ts.map +1 -0
- package/dist/src/command/validate-call.js +13 -0
- package/dist/src/command/validate-call.js.map +1 -0
- package/dist/src/config/index.d.ts +7 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +24 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/error/__tests__/fatal.spec.d.ts +2 -0
- package/dist/src/error/__tests__/fatal.spec.d.ts.map +1 -0
- package/dist/src/error/__tests__/fatal.spec.js +34 -0
- package/dist/src/error/__tests__/fatal.spec.js.map +1 -0
- package/dist/src/error/action.d.ts +9 -0
- package/dist/src/error/action.d.ts.map +1 -0
- package/dist/src/error/action.js +16 -0
- package/dist/src/error/action.js.map +1 -0
- package/dist/src/error/base.d.ts +11 -0
- package/dist/src/error/base.d.ts.map +1 -0
- package/dist/src/error/base.js +18 -0
- package/dist/src/error/base.js.map +1 -0
- package/dist/src/error/fatal.d.ts +10 -0
- package/dist/src/error/fatal.d.ts.map +1 -0
- package/dist/src/error/fatal.js +27 -0
- package/dist/src/error/fatal.js.map +1 -0
- package/dist/src/error/index.d.ts +18 -0
- package/dist/src/error/index.d.ts.map +1 -0
- package/dist/src/error/index.js +34 -0
- package/dist/src/error/index.js.map +1 -0
- package/dist/src/error/invalid-validator.d.ts +10 -0
- package/dist/src/error/invalid-validator.d.ts.map +1 -0
- package/dist/src/error/invalid-validator.js +15 -0
- package/dist/src/error/invalid-validator.js.map +1 -0
- package/dist/src/error/missing-argument.d.ts +11 -0
- package/dist/src/error/missing-argument.d.ts.map +1 -0
- package/dist/src/error/missing-argument.js +20 -0
- package/dist/src/error/missing-argument.js.map +1 -0
- package/dist/src/error/missing-flag.d.ts +11 -0
- package/dist/src/error/missing-flag.d.ts.map +1 -0
- package/dist/src/error/missing-flag.js +20 -0
- package/dist/src/error/missing-flag.js.map +1 -0
- package/dist/src/error/multi-validation.d.ts +10 -0
- package/dist/src/error/multi-validation.d.ts.map +1 -0
- package/dist/src/error/multi-validation.js +26 -0
- package/dist/src/error/multi-validation.js.map +1 -0
- package/dist/src/error/no-action.d.ts +10 -0
- package/dist/src/error/no-action.d.ts.map +1 -0
- package/dist/src/error/no-action.js +22 -0
- package/dist/src/error/no-action.js.map +1 -0
- package/dist/src/error/option-synopsis-syntax.d.ts +9 -0
- package/dist/src/error/option-synopsis-syntax.d.ts.map +1 -0
- package/dist/src/error/option-synopsis-syntax.js +15 -0
- package/dist/src/error/option-synopsis-syntax.js.map +1 -0
- package/dist/src/error/too-many-arguments.d.ts +11 -0
- package/dist/src/error/too-many-arguments.d.ts.map +1 -0
- package/dist/src/error/too-many-arguments.js +25 -0
- package/dist/src/error/too-many-arguments.js.map +1 -0
- package/dist/src/error/unknown-command.d.ts +13 -0
- package/dist/src/error/unknown-command.d.ts.map +1 -0
- package/dist/src/error/unknown-command.js +44 -0
- package/dist/src/error/unknown-command.js.map +1 -0
- package/dist/src/error/unknown-option.d.ts +13 -0
- package/dist/src/error/unknown-option.d.ts.map +1 -0
- package/dist/src/error/unknown-option.js +40 -0
- package/dist/src/error/unknown-option.js.map +1 -0
- package/dist/src/error/validation.d.ts +17 -0
- package/dist/src/error/validation.d.ts.map +1 -0
- package/dist/src/error/validation.js +49 -0
- package/dist/src/error/validation.js.map +1 -0
- package/dist/src/help/__tests__/help.spec.d.ts +2 -0
- package/dist/src/help/__tests__/help.spec.d.ts.map +1 -0
- package/dist/src/help/__tests__/help.spec.js +130 -0
- package/dist/src/help/__tests__/help.spec.js.map +1 -0
- package/dist/src/help/__tests__/utils.spec.d.ts +2 -0
- package/dist/src/help/__tests__/utils.spec.d.ts.map +1 -0
- package/dist/src/help/__tests__/utils.spec.js +16 -0
- package/dist/src/help/__tests__/utils.spec.js.map +1 -0
- package/dist/src/help/index.d.ts +47 -0
- package/dist/src/help/index.d.ts.map +1 -0
- package/dist/src/help/index.js +131 -0
- package/dist/src/help/index.js.map +1 -0
- package/dist/src/help/templates/command.d.ts +7 -0
- package/dist/src/help/templates/command.d.ts.map +1 -0
- package/dist/src/help/templates/command.js +23 -0
- package/dist/src/help/templates/command.js.map +1 -0
- package/dist/src/help/templates/custom.d.ts +7 -0
- package/dist/src/help/templates/custom.d.ts.map +1 -0
- package/dist/src/help/templates/custom.js +24 -0
- package/dist/src/help/templates/custom.js.map +1 -0
- package/dist/src/help/templates/header.d.ts +7 -0
- package/dist/src/help/templates/header.d.ts.map +1 -0
- package/dist/src/help/templates/header.js +16 -0
- package/dist/src/help/templates/header.js.map +1 -0
- package/dist/src/help/templates/index.d.ts +10 -0
- package/dist/src/help/templates/index.d.ts.map +1 -0
- package/dist/src/help/templates/index.js +26 -0
- package/dist/src/help/templates/index.js.map +1 -0
- package/dist/src/help/templates/program.d.ts +7 -0
- package/dist/src/help/templates/program.d.ts.map +1 -0
- package/dist/src/help/templates/program.js +18 -0
- package/dist/src/help/templates/program.js.map +1 -0
- package/dist/src/help/templates/usage.d.ts +7 -0
- package/dist/src/help/templates/usage.d.ts.map +1 -0
- package/dist/src/help/templates/usage.js +19 -0
- package/dist/src/help/templates/usage.js.map +1 -0
- package/dist/src/help/types.d.ts +53 -0
- package/dist/src/help/types.d.ts.map +1 -0
- package/dist/src/help/types.js +3 -0
- package/dist/src/help/types.js.map +1 -0
- package/dist/src/help/utils.d.ts +9 -0
- package/dist/src/help/utils.d.ts.map +1 -0
- package/dist/src/help/utils.js +92 -0
- package/dist/src/help/utils.js.map +1 -0
- package/dist/src/index.d.ts +90 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +111 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/logger/__tests__/logger.spec.d.ts +2 -0
- package/dist/src/logger/__tests__/logger.spec.d.ts.map +1 -0
- package/dist/src/logger/__tests__/logger.spec.js +56 -0
- package/dist/src/logger/__tests__/logger.spec.js.map +1 -0
- package/dist/src/logger/index.d.ts +6 -0
- package/dist/src/logger/index.d.ts.map +1 -0
- package/dist/src/logger/index.js +128 -0
- package/dist/src/logger/index.js.map +1 -0
- package/dist/src/option/__tests__/global.spec.d.ts +2 -0
- package/dist/src/option/__tests__/global.spec.d.ts.map +1 -0
- package/dist/src/option/__tests__/global.spec.js +121 -0
- package/dist/src/option/__tests__/global.spec.js.map +1 -0
- package/dist/src/option/__tests__/option.spec.d.ts +2 -0
- package/dist/src/option/__tests__/option.spec.d.ts.map +1 -0
- package/dist/src/option/__tests__/option.spec.js +111 -0
- package/dist/src/option/__tests__/option.spec.js.map +1 -0
- package/dist/src/option/find.d.ts +14 -0
- package/dist/src/option/find.d.ts.map +1 -0
- package/dist/src/option/find.js +17 -0
- package/dist/src/option/find.js.map +1 -0
- package/dist/src/option/index.d.ts +65 -0
- package/dist/src/option/index.d.ts.map +1 -0
- package/dist/src/option/index.js +230 -0
- package/dist/src/option/index.js.map +1 -0
- package/dist/src/option/mapping.d.ts +7 -0
- package/dist/src/option/mapping.d.ts.map +1 -0
- package/dist/src/option/mapping.js +21 -0
- package/dist/src/option/mapping.js.map +1 -0
- package/dist/src/option/utils.d.ts +35 -0
- package/dist/src/option/utils.d.ts.map +1 -0
- package/dist/src/option/utils.js +139 -0
- package/dist/src/option/utils.js.map +1 -0
- package/dist/src/option/validate.d.ts +15 -0
- package/dist/src/option/validate.d.ts.map +1 -0
- package/dist/src/option/validate.js +63 -0
- package/dist/src/option/validate.js.map +1 -0
- package/dist/src/parser/__tests__/parser.spec.d.ts +2 -0
- package/dist/src/parser/__tests__/parser.spec.d.ts.map +1 -0
- package/dist/src/parser/__tests__/parser.spec.js +343 -0
- package/dist/src/parser/__tests__/parser.spec.js.map +1 -0
- package/dist/src/parser/index.d.ts +17 -0
- package/dist/src/parser/index.d.ts.map +1 -0
- package/dist/src/parser/index.js +299 -0
- package/dist/src/parser/index.js.map +1 -0
- package/dist/src/program/__tests__/program.spec.d.ts +2 -0
- package/dist/src/program/__tests__/program.spec.d.ts.map +1 -0
- package/dist/src/program/__tests__/program.spec.js +261 -0
- package/dist/src/program/__tests__/program.spec.js.map +1 -0
- package/dist/src/program/index.d.ts +349 -0
- package/dist/src/program/index.d.ts.map +1 -0
- package/dist/src/program/index.js +584 -0
- package/dist/src/program/index.js.map +1 -0
- package/dist/src/types.d.ts +396 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +51 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/__tests__/fs.spec.d.ts +2 -0
- package/dist/src/utils/__tests__/fs.spec.d.ts.map +1 -0
- package/dist/src/utils/__tests__/fs.spec.js +14 -0
- package/dist/src/utils/__tests__/fs.spec.js.map +1 -0
- package/dist/src/utils/__tests__/levenshtein.spec.d.ts +2 -0
- package/dist/src/utils/__tests__/levenshtein.spec.d.ts.map +1 -0
- package/dist/src/utils/__tests__/levenshtein.spec.js +18 -0
- package/dist/src/utils/__tests__/levenshtein.spec.js.map +1 -0
- package/dist/src/utils/__tests__/suggest.spec.d.ts +2 -0
- package/dist/src/utils/__tests__/suggest.spec.d.ts.map +1 -0
- package/dist/src/utils/__tests__/suggest.spec.js +31 -0
- package/dist/src/utils/__tests__/suggest.spec.js.map +1 -0
- package/dist/src/utils/colorize.d.ts +2 -0
- package/dist/src/utils/colorize.d.ts.map +1 -0
- package/dist/src/utils/colorize.js +27 -0
- package/dist/src/utils/colorize.js.map +1 -0
- package/dist/src/utils/fs.d.ts +2 -0
- package/dist/src/utils/fs.d.ts.map +1 -0
- package/dist/src/utils/fs.js +19 -0
- package/dist/src/utils/fs.js.map +1 -0
- package/dist/src/utils/levenshtein.d.ts +6 -0
- package/dist/src/utils/levenshtein.d.ts.map +1 -0
- package/dist/src/utils/levenshtein.js +32 -0
- package/dist/src/utils/levenshtein.js.map +1 -0
- package/dist/src/utils/suggest.d.ts +15 -0
- package/dist/src/utils/suggest.d.ts.map +1 -0
- package/dist/src/utils/suggest.js +49 -0
- package/dist/src/utils/suggest.js.map +1 -0
- package/dist/src/utils/version.d.ts +2 -0
- package/dist/src/utils/version.d.ts.map +1 -0
- package/dist/src/utils/version.js +21 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/utils/web/autocomplete.d.ts +12 -0
- package/dist/src/utils/web/autocomplete.d.ts.map +1 -0
- package/dist/src/utils/web/autocomplete.js +12 -0
- package/dist/src/utils/web/autocomplete.js.map +1 -0
- package/dist/src/utils/web/process.d.ts +15 -0
- package/dist/src/utils/web/process.d.ts.map +1 -0
- package/dist/src/utils/web/process.js +29 -0
- package/dist/src/utils/web/process.js.map +1 -0
- package/dist/src/validator/__tests__/array.spec.d.ts +2 -0
- package/dist/src/validator/__tests__/array.spec.d.ts.map +1 -0
- package/dist/src/validator/__tests__/array.spec.js +34 -0
- package/dist/src/validator/__tests__/array.spec.js.map +1 -0
- package/dist/src/validator/__tests__/caporal.spec.d.ts +2 -0
- package/dist/src/validator/__tests__/caporal.spec.d.ts.map +1 -0
- package/dist/src/validator/__tests__/caporal.spec.js +86 -0
- package/dist/src/validator/__tests__/caporal.spec.js.map +1 -0
- package/dist/src/validator/__tests__/function.spec.d.ts +2 -0
- package/dist/src/validator/__tests__/function.spec.d.ts.map +1 -0
- package/dist/src/validator/__tests__/function.spec.js +42 -0
- package/dist/src/validator/__tests__/function.spec.js.map +1 -0
- package/dist/src/validator/__tests__/regexp.spec.d.ts +2 -0
- package/dist/src/validator/__tests__/regexp.spec.d.ts.map +1 -0
- package/dist/src/validator/__tests__/regexp.spec.js +34 -0
- package/dist/src/validator/__tests__/regexp.spec.js.map +1 -0
- package/dist/src/validator/__tests__/utils.spec.d.ts +2 -0
- package/dist/src/validator/__tests__/utils.spec.d.ts.map +1 -0
- package/dist/src/validator/__tests__/utils.spec.js +66 -0
- package/dist/src/validator/__tests__/utils.spec.js.map +1 -0
- package/dist/src/validator/__tests__/validate.spec.d.ts +2 -0
- package/dist/src/validator/__tests__/validate.spec.d.ts.map +1 -0
- package/dist/src/validator/__tests__/validate.spec.js +25 -0
- package/dist/src/validator/__tests__/validate.spec.js.map +1 -0
- package/dist/src/validator/array.d.ts +14 -0
- package/dist/src/validator/array.d.ts.map +1 -0
- package/dist/src/validator/array.js +29 -0
- package/dist/src/validator/array.js.map +1 -0
- package/dist/src/validator/caporal.d.ts +25 -0
- package/dist/src/validator/caporal.d.ts.map +1 -0
- package/dist/src/validator/caporal.js +89 -0
- package/dist/src/validator/caporal.js.map +1 -0
- package/dist/src/validator/function.d.ts +7 -0
- package/dist/src/validator/function.d.ts.map +1 -0
- package/dist/src/validator/function.js +27 -0
- package/dist/src/validator/function.js.map +1 -0
- package/dist/src/validator/regexp.d.ts +14 -0
- package/dist/src/validator/regexp.d.ts.map +1 -0
- package/dist/src/validator/regexp.js +31 -0
- package/dist/src/validator/regexp.js.map +1 -0
- package/dist/src/validator/utils.d.ts +14 -0
- package/dist/src/validator/utils.d.ts.map +1 -0
- package/dist/src/validator/utils.js +81 -0
- package/dist/src/validator/utils.js.map +1 -0
- package/dist/src/validator/validate.d.ts +7 -0
- package/dist/src/validator/validate.d.ts.map +1 -0
- package/dist/src/validator/validate.js +29 -0
- package/dist/src/validator/validate.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +75 -0
- package/src/__tests__/issue-163.spec.ts +18 -0
- package/src/argument/__tests__/argument.spec.ts +84 -0
- package/src/argument/find.ts +11 -0
- package/src/argument/index.ts +35 -0
- package/src/argument/synopsis.ts +41 -0
- package/src/argument/validate.ts +176 -0
- package/src/autocomplete/__fixtures__/prog-autocomplete.ts +24 -0
- package/src/autocomplete/__tests__/autocomplete.spec.ts +129 -0
- package/src/autocomplete/index.ts +225 -0
- package/src/autocomplete/types.ts +29 -0
- package/src/command/__fixtures__/example-cmd.ts +14 -0
- package/src/command/__tests__/command.spec.ts +621 -0
- package/src/command/__tests__/find.spec.ts +32 -0
- package/src/command/__tests__/import.spec.ts +14 -0
- package/src/command/__tests__/scan.spec.ts +16 -0
- package/src/command/find.ts +57 -0
- package/src/command/import.ts +13 -0
- package/src/command/index.ts +458 -0
- package/src/command/scan.ts +30 -0
- package/src/command/validate-call.ts +19 -0
- package/src/config/index.ts +26 -0
- package/src/error/__tests__/fatal.spec.ts +38 -0
- package/src/error/action.ts +13 -0
- package/src/error/base.ts +20 -0
- package/src/error/fatal.ts +25 -0
- package/src/error/index.ts +17 -0
- package/src/error/invalid-validator.ts +12 -0
- package/src/error/missing-argument.ts +16 -0
- package/src/error/missing-flag.ts +16 -0
- package/src/error/multi-validation.ts +22 -0
- package/src/error/no-action.ts +19 -0
- package/src/error/option-synopsis-syntax.ts +12 -0
- package/src/error/too-many-arguments.ts +28 -0
- package/src/error/unknown-command.ts +41 -0
- package/src/error/unknown-option.ts +40 -0
- package/src/error/validation.ts +80 -0
- package/src/help/__tests__/__snapshots__/help.spec.ts.snap +334 -0
- package/src/help/__tests__/help.spec.ts +144 -0
- package/src/help/__tests__/utils.spec.ts +14 -0
- package/src/help/index.ts +107 -0
- package/src/help/templates/command.ts +27 -0
- package/src/help/templates/custom.ts +25 -0
- package/src/help/templates/header.ts +19 -0
- package/src/help/templates/index.ts +9 -0
- package/src/help/templates/program.ts +21 -0
- package/src/help/templates/usage.ts +24 -0
- package/src/help/types.ts +57 -0
- package/src/help/utils.ts +109 -0
- package/src/index.ts +93 -0
- package/src/logger/__tests__/logger.spec.ts +65 -0
- package/src/logger/index.ts +97 -0
- package/src/option/__tests__/global.spec.ts +141 -0
- package/src/option/__tests__/option.spec.ts +115 -0
- package/src/option/find.ts +17 -0
- package/src/option/index.ts +280 -0
- package/src/option/mapping.ts +17 -0
- package/src/option/utils.ts +141 -0
- package/src/option/validate.ts +80 -0
- package/src/parser/__tests__/parser.spec.ts +371 -0
- package/src/parser/index.ts +383 -0
- package/src/program/__tests__/program.spec.ts +316 -0
- package/src/program/index.ts +676 -0
- package/src/types.ts +432 -0
- package/src/utils/__tests__/fs.spec.ts +14 -0
- package/src/utils/__tests__/levenshtein.spec.ts +16 -0
- package/src/utils/__tests__/suggest.spec.ts +30 -0
- package/src/utils/colorize.ts +21 -0
- package/src/utils/fs.ts +13 -0
- package/src/utils/levenshtein.ts +28 -0
- package/src/utils/suggest.ts +52 -0
- package/src/utils/version.ts +14 -0
- package/src/utils/web/autocomplete.ts +19 -0
- package/src/utils/web/process.ts +24 -0
- package/src/validator/__tests__/array.spec.ts +41 -0
- package/src/validator/__tests__/caporal.spec.ts +132 -0
- package/src/validator/__tests__/function.spec.ts +52 -0
- package/src/validator/__tests__/regexp.spec.ts +38 -0
- package/src/validator/__tests__/utils.spec.ts +67 -0
- package/src/validator/__tests__/validate.spec.ts +24 -0
- package/src/validator/array.ts +31 -0
- package/src/validator/caporal.ts +104 -0
- package/src/validator/function.ts +31 -0
- package/src/validator/regexp.ts +34 -0
- package/src/validator/utils.ts +84 -0
- package/src/validator/validate.ts +38 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
const program_1 = require("../../program");
|
|
8
|
+
const command_1 = require("../../command");
|
|
9
|
+
const find_1 = require("../../command/find");
|
|
10
|
+
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
11
|
+
const vitest_1 = require("vitest");
|
|
12
|
+
(0, vitest_1.describe)("help", () => {
|
|
13
|
+
let prog = new program_1.Program();
|
|
14
|
+
(0, vitest_1.beforeEach)(() => {
|
|
15
|
+
prog = new program_1.Program();
|
|
16
|
+
prog.name("test-prog");
|
|
17
|
+
prog.bin("test-prog");
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.describe)("tpl()", () => {
|
|
20
|
+
(0, vitest_1.it)("should compile template with given context", () => {
|
|
21
|
+
const cmd = (0, command_1.createCommand)(prog, "test", "test command");
|
|
22
|
+
const ctx = (0, __1.getContext)(prog, cmd);
|
|
23
|
+
return (0, vitest_1.expect)((0, __1.tpl)("header", ctx)).resolves.toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.it)("should compile a custom template with given context", async () => {
|
|
26
|
+
const cmd = (0, command_1.createCommand)(prog, "test", "test command");
|
|
27
|
+
const ctx = (0, __1.getContext)(prog, cmd);
|
|
28
|
+
(0, __1.registerTemplate)("mine", () => "template-contents");
|
|
29
|
+
(0, vitest_1.expect)(await (0, __1.tpl)("mine", ctx)).toBe("template-contents");
|
|
30
|
+
});
|
|
31
|
+
(0, vitest_1.it)("should fail if template does not exist", () => {
|
|
32
|
+
const cmd = (0, command_1.createCommand)(prog, "test", "test command");
|
|
33
|
+
const ctx = (0, __1.getContext)(prog, cmd);
|
|
34
|
+
return (0, vitest_1.expect)((0, __1.tpl)("unknown", ctx)).rejects.toBeInstanceOf(Error);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
(0, vitest_1.describe)("getHelp()", () => {
|
|
38
|
+
(0, vitest_1.it)("should display help for a basic program", async () => {
|
|
39
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.it)("should display help for a program-command", async () => {
|
|
42
|
+
prog
|
|
43
|
+
.argument("<foo>", "Mandarory foo arg")
|
|
44
|
+
.argument("[other]", "Other args")
|
|
45
|
+
.option("-f, --file <file>", "Output file");
|
|
46
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.it)("should display help for a program having at least one command (with args & options)", async () => {
|
|
49
|
+
prog
|
|
50
|
+
.command("test-command", "Test command")
|
|
51
|
+
.argument("<foo>", "Mandarory foo arg")
|
|
52
|
+
.argument("[other]", "Other args")
|
|
53
|
+
.option("-f, --file <file>", "Output file");
|
|
54
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
(0, vitest_1.it)("should display help for a program having at least one command (with args only)", async () => {
|
|
57
|
+
prog
|
|
58
|
+
.command("test-command", "Test command")
|
|
59
|
+
.argument("<foo>", "Mandarory foo arg")
|
|
60
|
+
.argument("[other]", "Other args");
|
|
61
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.it)("should display help for a program having at least one command (with options only)", async () => {
|
|
64
|
+
prog
|
|
65
|
+
.command("test-command", "Test command")
|
|
66
|
+
.option("-f, --file <file>", "Output file");
|
|
67
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.it)("should handle required options", async () => {
|
|
70
|
+
prog
|
|
71
|
+
.command("test-command", "Test command")
|
|
72
|
+
.option("-f, --file <file>", "Output file", { required: true });
|
|
73
|
+
const cmd = await (0, find_1.findCommand)(prog, ["test-command"]);
|
|
74
|
+
(0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog, cmd))).toContain("required");
|
|
75
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog, cmd))).toMatchSnapshot();
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.it)("should handle type hints", async () => {
|
|
78
|
+
prog
|
|
79
|
+
.command("test-command", "Test command")
|
|
80
|
+
.argument("<foo>", "Desc", { validator: prog.NUMBER })
|
|
81
|
+
.option("-f, --file <file>", "Output file", {
|
|
82
|
+
required: true,
|
|
83
|
+
validator: prog.NUMBER,
|
|
84
|
+
});
|
|
85
|
+
const cmd = await (0, find_1.findCommand)(prog, ["test-command"]);
|
|
86
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog, cmd))).toMatchSnapshot();
|
|
87
|
+
});
|
|
88
|
+
(0, vitest_1.it)("should work with a program without a specified name", async () => {
|
|
89
|
+
prog = new program_1.Program();
|
|
90
|
+
prog.bin("test-prog");
|
|
91
|
+
prog
|
|
92
|
+
.command("test-command", "Test command")
|
|
93
|
+
.option("-f, --file <file>", "Output file");
|
|
94
|
+
return (0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
(0, vitest_1.it)("should work with a program without a version", async () => {
|
|
97
|
+
prog = new program_1.Program();
|
|
98
|
+
prog.bin("test-prog");
|
|
99
|
+
prog.version("");
|
|
100
|
+
prog
|
|
101
|
+
.command("test-command", "Test command")
|
|
102
|
+
.option("-f, --file <file>", "Output file");
|
|
103
|
+
(0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
104
|
+
});
|
|
105
|
+
(0, vitest_1.it)("should display program description", async () => {
|
|
106
|
+
prog.description("Description test");
|
|
107
|
+
prog
|
|
108
|
+
.command("test-command", "Test command")
|
|
109
|
+
.option("-f, --file <file>", "Output file");
|
|
110
|
+
(0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
111
|
+
});
|
|
112
|
+
(0, vitest_1.it)("should display customized program help", async () => {
|
|
113
|
+
prog.description("Description test");
|
|
114
|
+
prog
|
|
115
|
+
.help("My custom help")
|
|
116
|
+
.command("test-command", "Test command")
|
|
117
|
+
.option("-f, --file <file>", "Output file");
|
|
118
|
+
(0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
119
|
+
});
|
|
120
|
+
(0, vitest_1.it)("should display customized program help on multiple lines", async () => {
|
|
121
|
+
prog.description("Description test");
|
|
122
|
+
prog
|
|
123
|
+
.command("test-command", "Test command")
|
|
124
|
+
.option("-f, --file <file>", "Output file")
|
|
125
|
+
.help("My custom help\nAnother line\nOne last line");
|
|
126
|
+
(0, vitest_1.expect)((0, strip_ansi_1.default)(await (0, __1.getHelp)(prog))).toMatchSnapshot();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=help.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.spec.js","sourceRoot":"","sources":["../../../../src/help/__tests__/help.spec.ts"],"names":[],"mappings":";;;;;AAAA,0BAA+D;AAC/D,2CAAuC;AACvC,2CAA6C;AAC7C,6CAAgD;AAChD,4DAA8B;AAC9B,mCAAyD;AAEzD,IAAA,iBAAQ,EAAC,MAAM,EAAE,GAAG,EAAE;IACpB,IAAI,IAAI,GAAG,IAAI,iBAAO,EAAE,CAAA;IAExB,IAAA,mBAAU,EAAC,GAAG,EAAE;QACd,IAAI,GAAG,IAAI,iBAAO,EAAE,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACtB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,IAAA,iBAAQ,EAAC,OAAO,EAAE,GAAG,EAAE;QACrB,IAAA,WAAE,EAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,CAAA;YACvD,MAAM,GAAG,GAAG,IAAA,cAAU,EAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YACjC,OAAO,IAAA,eAAM,EAAC,IAAA,OAAG,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAA;QAC9D,CAAC,CAAC,CAAA;QAEF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I,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAA;YACpC,IAAI;iBACD,IAAI,CAAC,gBAAgB,CAAC;iBACtB,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC;iBACvC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAA;YAC7C,IAAA,eAAM,EAAC,IAAA,oBAAK,EAAC,MAAM,IAAA,WAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAA;QACtD,CAAC,CAAC,CAAA;QAEF,IAAA,WAAE,EAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;YACxE,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAA;YACpC,IAAI;iBACD,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC;iBACvC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC;iBAC1C,IAAI,CAAC,6CAA6C,CAAC,CAAA;YACtD,IAAA,eAAM,EAAC,IAAA,oBAAK,EAAC,MAAM,IAAA,WAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAA;QACtD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.spec.d.ts","sourceRoot":"","sources":["../../../../src/help/__tests__/utils.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const argument_1 = require("../../argument");
|
|
5
|
+
const caporal_1 = require("../../validator/caporal");
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
(0, vitest_1.describe)("help/utils", () => {
|
|
8
|
+
(0, vitest_1.it)("getDefaultValueHint() should return the correct value hint", () => {
|
|
9
|
+
const arg = (0, argument_1.createArgument)("<arg>", "My arg", {
|
|
10
|
+
validator: caporal_1.CaporalValidator.BOOLEAN,
|
|
11
|
+
default: true,
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.expect)((0, utils_1.getDefaultValueHint)(arg)).toBe("default: true");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=utils.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../../src/help/__tests__/utils.spec.ts"],"names":[],"mappings":";;AAAA,oCAA8C;AAC9C,6CAA+C;AAC/C,qDAA0D;AAC1D,mCAA6C;AAE7C,IAAA,iBAAQ,EAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAA,WAAE,EAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,GAAG,GAAG,IAAA,yBAAc,EAAC,OAAO,EAAE,QAAQ,EAAE;YAC5C,SAAS,EAAE,0BAAgB,CAAC,OAAO;YACnC,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QACF,IAAA,eAAM,EAAC,IAAA,2BAAmB,EAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module caporal/help
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from "../command";
|
|
6
|
+
import { Program } from "../program";
|
|
7
|
+
import { CustomizedHelpOpts, TemplateContext, Template } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Customize the help
|
|
10
|
+
*
|
|
11
|
+
* @param obj
|
|
12
|
+
* @param text
|
|
13
|
+
* @param options
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function customizeHelp(obj: Command | Program, text: string, options: Partial<CustomizedHelpOpts>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Register a new help template
|
|
19
|
+
*
|
|
20
|
+
* @param name Template name
|
|
21
|
+
* @param template Template function
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerTemplate(name: string, template: Template): Map<string, Template>;
|
|
25
|
+
/**
|
|
26
|
+
* Helper to be used to call templates from within templates
|
|
27
|
+
*
|
|
28
|
+
* @param name Template name
|
|
29
|
+
* @param ctx Execution context
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare function tpl(name: string, ctx: TemplateContext): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
* @param program
|
|
36
|
+
* @param command
|
|
37
|
+
*/
|
|
38
|
+
export declare function getContext(program: Program, command?: Command): TemplateContext;
|
|
39
|
+
/**
|
|
40
|
+
* Return the help text
|
|
41
|
+
*
|
|
42
|
+
* @param program Program instance
|
|
43
|
+
* @param command Command instance, if any
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export declare function getHelp(program: Program, command?: Command): Promise<string>;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/help/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAOpC,OAAO,EAAqB,kBAAkB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAK1F;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,GAAG,OAAO,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACnC,IAAI,CASN;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,GACjB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAEvB;AAED;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAM7E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,eAAe,CAoB/E;AAED;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.customizeHelp = customizeHelp;
|
|
40
|
+
exports.registerTemplate = registerTemplate;
|
|
41
|
+
exports.tpl = tpl;
|
|
42
|
+
exports.getContext = getContext;
|
|
43
|
+
exports.getHelp = getHelp;
|
|
44
|
+
const replace_1 = __importDefault(require("lodash/replace"));
|
|
45
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
const utils_1 = require("./utils");
|
|
47
|
+
const colorize_1 = require("../utils/colorize");
|
|
48
|
+
const allTemplates = __importStar(require("./templates"));
|
|
49
|
+
const option_1 = require("../option");
|
|
50
|
+
const templates = new Map(Object.entries(allTemplates));
|
|
51
|
+
const customHelpMap = new Map();
|
|
52
|
+
/**
|
|
53
|
+
* Customize the help
|
|
54
|
+
*
|
|
55
|
+
* @param obj
|
|
56
|
+
* @param text
|
|
57
|
+
* @param options
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
function customizeHelp(obj, text, options) {
|
|
61
|
+
const opts = {
|
|
62
|
+
sectionName: "",
|
|
63
|
+
colorize: true,
|
|
64
|
+
...options,
|
|
65
|
+
};
|
|
66
|
+
const data = customHelpMap.get(obj) || [];
|
|
67
|
+
data.push({ text, options: opts });
|
|
68
|
+
customHelpMap.set(obj, data);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Register a new help template
|
|
72
|
+
*
|
|
73
|
+
* @param name Template name
|
|
74
|
+
* @param template Template function
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
function registerTemplate(name, template) {
|
|
78
|
+
return templates.set(name, template);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Helper to be used to call templates from within templates
|
|
82
|
+
*
|
|
83
|
+
* @param name Template name
|
|
84
|
+
* @param ctx Execution context
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
async function tpl(name, ctx) {
|
|
88
|
+
const template = templates.get(name);
|
|
89
|
+
if (!template) {
|
|
90
|
+
throw Error(`Caporal setup error: Unknown help template '${name}'`);
|
|
91
|
+
}
|
|
92
|
+
return template(ctx);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
* @param program
|
|
97
|
+
* @param command
|
|
98
|
+
*/
|
|
99
|
+
function getContext(program, command) {
|
|
100
|
+
const spaces = " ".repeat(2);
|
|
101
|
+
const ctx = {
|
|
102
|
+
prog: program,
|
|
103
|
+
cmd: command,
|
|
104
|
+
chalk: chalk_1.default,
|
|
105
|
+
colorize: colorize_1.colorize,
|
|
106
|
+
customHelp: customHelpMap,
|
|
107
|
+
tpl,
|
|
108
|
+
globalOptions: (0, option_1.getGlobalOptions)(),
|
|
109
|
+
table: utils_1.buildTable,
|
|
110
|
+
spaces,
|
|
111
|
+
indent(str, sp = spaces) {
|
|
112
|
+
return sp + (0, replace_1.default)(str.trim(), /(\r\n|\r|\n)/g, "\n" + sp);
|
|
113
|
+
},
|
|
114
|
+
eol: "\n",
|
|
115
|
+
eol2: "\n\n",
|
|
116
|
+
eol3: "\n\n\n",
|
|
117
|
+
};
|
|
118
|
+
return ctx;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Return the help text
|
|
122
|
+
*
|
|
123
|
+
* @param program Program instance
|
|
124
|
+
* @param command Command instance, if any
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
async function getHelp(program, command) {
|
|
128
|
+
const ctx = getContext(program, command);
|
|
129
|
+
return [await tpl("header", ctx), await tpl("usage", ctx)].join("");
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/help/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,sCAaC;AASD,4CAKC;AASD,kBAMC;AAOD,gCAoBC;AASD,0BAGC;AApGD,6DAAoC;AACpC,kDAAyB;AACzB,mCAAoC;AACpC,gDAA4C;AAC5C,0DAA2C;AAC3C,sCAA4C;AAG5C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;AACvD,MAAM,aAAa,GAAsB,IAAI,GAAG,EAAE,CAAA;AAElD;;;;;;;GAOG;AACH,SAAgB,aAAa,CAC3B,GAAsB,EACtB,IAAY,EACZ,OAAoC;IAEpC,MAAM,IAAI,GAAuB;QAC/B,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE,IAAI;QACd,GAAG,OAAO;KACX,CAAA;IACD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACzC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAClC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC9B,IAAY,EACZ,QAAkB;IAElB,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,GAAG,CAAC,IAAY,EAAE,GAAoB;IAC1D,MAAM,Q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ot":"","sources":["../../../../src/help/templates/command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,UAAU,CAAA;AAIzD,eAAO,MAAM,OAAO,EAAE,QAiBrB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.command = void 0;
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const sortBy_1 = __importDefault(require("lodash/sortBy"));
|
|
9
|
+
const command = async (ctx) => {
|
|
10
|
+
const { cmd, globalOptions: globalFlags, eol, eol3, colorize, tpl } = ctx;
|
|
11
|
+
const options = (0, sortBy_1.default)(cmd.options, "name"), globalOptions = Array.from(globalFlags.keys());
|
|
12
|
+
const help = cmd.synopsis +
|
|
13
|
+
eol3 +
|
|
14
|
+
(await tpl("custom", ctx)) +
|
|
15
|
+
(0, utils_1.getArgumentsTable)(cmd.args, ctx) +
|
|
16
|
+
eol +
|
|
17
|
+
(0, utils_1.getOptionsTable)(options, ctx) +
|
|
18
|
+
eol +
|
|
19
|
+
(0, utils_1.getOptionsTable)(globalOptions, ctx, "GLOBAL OPTIONS");
|
|
20
|
+
return colorize(help);
|
|
21
|
+
};
|
|
22
|
+
exports.command = command;
|
|
23
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/help/templates/command.ts"],"names":[],"mappings":";;;;;;AAMA,oCAA6D;AAC7D,2DAAkC;AAE3B,MAAM,OAAO,GAAa,KAAK,EAAE,GAAoB,EAAE,EAAE;IAC9D,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAEzE,MAAM,OAAO,GAAG,IAAA,gBAAM,EAAC,GAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAC1C,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAA;IAEhD,MAAM,IAAI,GACR,GAAI,CAAC,QAAQ;QACb,IAAI;QACJ,CAAC,MAAM,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAA,yBAAiB,EAAC,GAAI,CAAC,IAAI,EAAE,GAAG,CAAC;QACjC,GAAG;QACH,IAAA,uBAAe,EAAC,OAAO,EAAE,GAAG,CAAC;QAC7B,GAAG;QACH,IAAA,uBAAe,EAAC,aAAa,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAEvD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA;AAjBY,QAAA,OAAO,WAiBnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../../src/help/templates/custom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEzD,eAAO,MAAM,MAAM,EAAE,QAkBpB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.custom = void 0;
|
|
4
|
+
const custom = (ctx) => {
|
|
5
|
+
const { prog, cmd, eol2, eol3, chalk, colorize, customHelp, indent } = ctx;
|
|
6
|
+
const data = customHelp.get(cmd || prog);
|
|
7
|
+
if (data) {
|
|
8
|
+
const txt = data
|
|
9
|
+
.map(({ text, options }) => {
|
|
10
|
+
let str = "";
|
|
11
|
+
if (options.sectionName) {
|
|
12
|
+
str += chalk.bold(options.sectionName) + eol2;
|
|
13
|
+
}
|
|
14
|
+
const subtxt = options.colorize ? colorize(text) : text;
|
|
15
|
+
str += options.sectionName ? indent(subtxt) : subtxt;
|
|
16
|
+
return str + eol3;
|
|
17
|
+
})
|
|
18
|
+
.join("");
|
|
19
|
+
return indent(txt) + eol3;
|
|
20
|
+
}
|
|
21
|
+
return "";
|
|
22
|
+
};
|
|
23
|
+
exports.custom = custom;
|
|
24
|
+
//# sourceMappingURL=custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../../../src/help/templates/custom.ts"],"names":[],"mappings":";;;AAMO,MAAM,MAAM,GAAa,CAAC,GAAoB,EAAE,EAAE;IACvD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;IAC1E,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,CAAA;IACxC,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,GAAG,GAAG,IAAI;aACb,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;YACzB,IAAI,GAAG,GAAG,EAAE,CAAA;YACZ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;gBACxB,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;YAC/C,CAAC;YACD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YACvD,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YACpD,OAAO,GAAG,GAAG,IAAI,CAAA;QACnB,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAA;QACX,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;IAC3B,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAlBY,QAAA,MAAM,UAkBlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../src/help/templates/header.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEzD,eAAO,MAAM,MAAM,EAAE,QAYpB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.header = void 0;
|
|
4
|
+
const header = (ctx) => {
|
|
5
|
+
const { prog, chalk: c, spaces, eol, eol2 } = ctx;
|
|
6
|
+
const version = process.env?.NODE_ENV === "test" ? "" : prog.getVersion();
|
|
7
|
+
return (eol +
|
|
8
|
+
spaces +
|
|
9
|
+
(prog.getName() || prog.getBin()) +
|
|
10
|
+
" " +
|
|
11
|
+
(version || "") +
|
|
12
|
+
(prog.getDescription() ? " \u2014 " + c.dim(prog.getDescription()) : "") +
|
|
13
|
+
eol2);
|
|
14
|
+
};
|
|
15
|
+
exports.header = header;
|
|
16
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.js","sourceRoot":"","sources":["../../../../src/help/templates/header.ts"],"names":[],"mappings":";;;AAMO,MAAM,MAAM,GAAa,CAAC,GAAoB,EAAE,EAAE;IACvD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAA;IACzE,OAAO,CACL,GAAG;QACH,MAAM;QACN,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACjC,GAAG;QACH,CAAC,OAAO,IAAI,EAAE,CAAC;QACf,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,IAAI,CACL,CAAA;AACH,CAAC,CAAA;AAZY,QAAA,MAAM,UAYlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/help/templates/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
__exportStar(require("./command"), exports);
|
|
22
|
+
__exportStar(require("./header"), exports);
|
|
23
|
+
__exportStar(require("./program"), exports);
|
|
24
|
+
__exportStar(require("./usage"), exports);
|
|
25
|
+
__exportStar(require("./custom"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/help/templates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,4CAAyB;AACzB,2CAAwB;AACxB,4CAAyB;AACzB,0CAAuB;AACvB,2CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../../src/help/templates/program.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGzD,eAAO,MAAM,OAAO,EAAE,QAarB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.program = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const program = async (ctx) => {
|
|
6
|
+
const { prog, globalOptions, eol, eol3, colorize, tpl } = ctx;
|
|
7
|
+
const commands = await prog.getAllCommands();
|
|
8
|
+
const options = Array.from(globalOptions.keys());
|
|
9
|
+
const help = (await prog.getSynopsis()) +
|
|
10
|
+
eol3 +
|
|
11
|
+
(await tpl("custom", ctx)) +
|
|
12
|
+
(0, utils_1.getCommandsTable)(commands, ctx) +
|
|
13
|
+
eol +
|
|
14
|
+
(0, utils_1.getOptionsTable)(options, ctx, "GLOBAL OPTIONS");
|
|
15
|
+
return colorize(help);
|
|
16
|
+
};
|
|
17
|
+
exports.program = program;
|
|
18
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../../../src/help/templates/program.ts"],"names":[],"mappings":";;;AAKA,oCAA4D;AAErD,MAAM,OAAO,GAAa,KAAK,EAAE,GAAoB,EAAE,EAAE;IAC9D,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAC7D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;IAChD,MAAM,IAAI,GACR,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1B,IAAI;QACJ,CAAC,MAAM,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAA,wBAAgB,EAAC,QAAQ,EAAE,GAAG,CAAC;QAC/B,GAAG;QACH,IAAA,uBAAe,EAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAEjD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA;AAbY,QAAA,OAAO,WAanB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../../src/help/templates/usage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEzD,eAAO,MAAM,KAAK,EAAE,QAiBnB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usage = void 0;
|
|
4
|
+
const usage = async (ctx) => {
|
|
5
|
+
const { tpl, prog, chalk: c, spaces, eol } = ctx;
|
|
6
|
+
let { cmd } = ctx;
|
|
7
|
+
// if help is asked without a `cmd` and that no command exists
|
|
8
|
+
// within the program, override `cmd` with the program-command
|
|
9
|
+
if (!cmd && !(await prog.hasCommands())) {
|
|
10
|
+
ctx.cmd = cmd = prog.progCommand;
|
|
11
|
+
}
|
|
12
|
+
// usage
|
|
13
|
+
const usage = `${spaces + c.bold("USAGE")} ${cmd?.name ? "— " + c.dim(cmd.name) : ""}
|
|
14
|
+
${eol + spaces + spaces + c.dim("\u25B8")} `;
|
|
15
|
+
const next = cmd ? await tpl("command", ctx) : await tpl("program", ctx);
|
|
16
|
+
return usage + next;
|
|
17
|
+
};
|
|
18
|
+
exports.usage = usage;
|
|
19
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../../src/help/templates/usage.ts"],"names":[],"mappings":";;;AAMO,MAAM,KAAK,GAAa,KAAK,EAAE,GAAoB,EAAE,EAAE;IAC5D,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAChD,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAEjB,8DAA8D;IAC9D,8DAA8D;IAC9D,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QACxC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,CAAA;IAClC,CAAC;IAED,QAAQ;IACR,MAAM,KAAK,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;IAClF,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAA;IAE5C,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IAExE,OAAO,KAAK,GAAG,IAAI,CAAA;AACrB,CAAC,CAAA;AAjBY,QAAA,KAAK,SAiBjB"}
|