zod-args-parser 2.0.0-beta.1 → 2.0.0-beta.3
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 +1 -0
- package/README.md +244 -282
- package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js +74 -2
- package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js.map +7 -1
- package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js +90 -2
- package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js.map +7 -1
- package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js +39 -13
- package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js.map +7 -1
- package/lib/esm/cli-error/cli-error.js +38 -0
- package/lib/esm/cli-error/cli-error.js.map +7 -0
- package/lib/esm/cli-error/error-cause.js +12 -0
- package/lib/esm/cli-error/error-cause.js.map +7 -0
- package/lib/esm/cli-error/error-code/definition-error-code.js +23 -0
- package/lib/esm/cli-error/error-code/definition-error-code.js.map +7 -0
- package/lib/esm/cli-error/error-code/internal-error-code.js +10 -0
- package/lib/esm/cli-error/error-code/internal-error-code.js.map +7 -0
- package/lib/esm/cli-error/error-code/parse-error-code.js +18 -0
- package/lib/esm/cli-error/error-code/parse-error-code.js.map +7 -0
- package/lib/esm/cli-error/error-code/validation-error-code.js +17 -0
- package/lib/esm/cli-error/error-code/validation-error-code.js.map +7 -0
- package/lib/esm/cli-error/error-message/definition-error-message.js +70 -0
- package/lib/esm/cli-error/error-message/definition-error-message.js.map +7 -0
- package/lib/esm/cli-error/error-message/internal-error-message.js +16 -0
- package/lib/esm/cli-error/error-message/internal-error-message.js.map +7 -0
- package/lib/esm/cli-error/error-message/parse-error-message.js +40 -0
- package/lib/esm/cli-error/error-message/parse-error-message.js.map +7 -0
- package/lib/esm/cli-error/error-message/validation-error-message.js +60 -0
- package/lib/esm/cli-error/error-message/validation-error-message.js.map +7 -0
- package/lib/esm/coerce/coerce-methods.js +197 -2
- package/lib/esm/coerce/coerce-methods.js.map +7 -1
- package/lib/esm/coerce/string-to-array.js +17 -2
- package/lib/esm/coerce/string-to-array.js.map +7 -1
- package/lib/esm/coerce/string-to-primitive.js +73 -2
- package/lib/esm/coerce/string-to-primitive.js.map +7 -1
- package/lib/esm/coerce/string-to-set.js +17 -2
- package/lib/esm/coerce/string-to-set.js.map +7 -1
- package/lib/esm/definitions/define-arguments.js +10 -2
- package/lib/esm/definitions/define-arguments.js.map +7 -1
- package/lib/esm/definitions/define-cli.js +89 -2
- package/lib/esm/definitions/define-cli.js.map +7 -1
- package/lib/esm/definitions/define-options.js +10 -2
- package/lib/esm/definitions/define-options.js.map +7 -1
- package/lib/esm/definitions/define-subcommand.js +56 -2
- package/lib/esm/definitions/define-subcommand.js.map +7 -1
- package/lib/esm/definitions/validate-cli-definition.js +360 -2
- package/lib/esm/definitions/validate-cli-definition.js.map +7 -1
- package/lib/esm/help-message/format-arguments.js +48 -2
- package/lib/esm/help-message/format-arguments.js.map +7 -1
- package/lib/esm/help-message/format-options.js +50 -2
- package/lib/esm/help-message/format-options.js.map +7 -1
- package/lib/esm/help-message/format-subcommands.js +37 -2
- package/lib/esm/help-message/format-subcommands.js.map +7 -1
- package/lib/esm/help-message/generate-for-cli.js +71 -2
- package/lib/esm/help-message/generate-for-cli.js.map +7 -1
- package/lib/esm/help-message/generate-for-subcommand.js +23 -2
- package/lib/esm/help-message/generate-for-subcommand.js.map +7 -1
- package/lib/esm/help-message/print-help.js +14 -2
- package/lib/esm/help-message/print-help.js.map +7 -1
- package/lib/esm/help-message/set-defaults.js +29 -2
- package/lib/esm/help-message/set-defaults.js.map +7 -1
- package/lib/esm/help-message/styles.js +154 -2
- package/lib/esm/help-message/styles.js.map +7 -1
- package/lib/esm/help-message/terminal-markdown.js +121 -2
- package/lib/esm/help-message/terminal-markdown.js.map +7 -1
- package/lib/esm/index.js +52 -2
- package/lib/esm/index.js.map +7 -1
- package/lib/esm/markdown/generate-markdown.js +153 -2
- package/lib/esm/markdown/generate-markdown.js.map +7 -1
- package/lib/esm/metadata/arguments-metadata.js +26 -2
- package/lib/esm/metadata/arguments-metadata.js.map +7 -1
- package/lib/esm/metadata/cli-metadata.js +24 -2
- package/lib/esm/metadata/cli-metadata.js.map +7 -1
- package/lib/esm/metadata/options-metadata.js +35 -2
- package/lib/esm/metadata/options-metadata.js.map +7 -1
- package/lib/esm/metadata/subcommands-metadata.js +32 -2
- package/lib/esm/metadata/subcommands-metadata.js.map +7 -1
- package/lib/esm/parse/context/cli-context-builder.js +283 -2
- package/lib/esm/parse/context/cli-context-builder.js.map +7 -1
- package/lib/esm/parse/context/object-context-builder.js +62 -2
- package/lib/esm/parse/context/object-context-builder.js.map +7 -1
- package/lib/esm/parse/parser-utilities.js +108 -2
- package/lib/esm/parse/parser-utilities.js.map +7 -1
- package/lib/esm/parse/safe-parse.js +57 -2
- package/lib/esm/parse/safe-parse.js.map +7 -1
- package/lib/esm/parse/validation/validate-context.js +17 -2
- package/lib/esm/parse/validation/validate-context.js.map +7 -1
- package/lib/esm/parse/validation/validators/arguments.js +67 -2
- package/lib/esm/parse/validation/validators/arguments.js.map +7 -1
- package/lib/esm/parse/validation/validators/conflict.js +38 -2
- package/lib/esm/parse/validation/validators/conflict.js.map +7 -1
- package/lib/esm/parse/validation/validators/exclusive.js +39 -2
- package/lib/esm/parse/validation/validators/exclusive.js.map +7 -1
- package/lib/esm/parse/validation/validators/explicitly-passed.js +18 -2
- package/lib/esm/parse/validation/validators/explicitly-passed.js.map +7 -1
- package/lib/esm/parse/validation/validators/options.js +67 -2
- package/lib/esm/parse/validation/validators/options.js.map +7 -1
- package/lib/esm/parse/validation/validators/requires.js +43 -2
- package/lib/esm/parse/validation/validators/requires.js.map +7 -1
- package/lib/esm/utilities/parse-argv.js +61 -0
- package/lib/esm/utilities/parse-argv.js.map +7 -0
- package/lib/esm/utilities/schema-utilities.js +57 -0
- package/lib/esm/utilities/schema-utilities.js.map +7 -0
- package/lib/esm/utilities/utilities.js +122 -0
- package/lib/esm/utilities/utilities.js.map +7 -0
- package/lib/iife/index.js +41 -1
- package/lib/iife/index.js.map +1 -1
- package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs +74 -2
- package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs.map +7 -1
- package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs +90 -2
- package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs.map +7 -1
- package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs +39 -13
- package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs.map +7 -1
- package/lib/mjs/cli-error/cli-error.mjs +38 -0
- package/lib/mjs/cli-error/cli-error.mjs.map +7 -0
- package/lib/mjs/cli-error/error-cause.mjs +12 -0
- package/lib/mjs/cli-error/error-cause.mjs.map +7 -0
- package/lib/mjs/cli-error/error-code/definition-error-code.mjs +23 -0
- package/lib/mjs/cli-error/error-code/definition-error-code.mjs.map +7 -0
- package/lib/mjs/cli-error/error-code/internal-error-code.mjs +10 -0
- package/lib/mjs/cli-error/error-code/internal-error-code.mjs.map +7 -0
- package/lib/mjs/cli-error/error-code/parse-error-code.mjs +18 -0
- package/lib/mjs/cli-error/error-code/parse-error-code.mjs.map +7 -0
- package/lib/mjs/cli-error/error-code/validation-error-code.mjs +17 -0
- package/lib/mjs/cli-error/error-code/validation-error-code.mjs.map +7 -0
- package/lib/mjs/cli-error/error-message/definition-error-message.mjs +70 -0
- package/lib/mjs/cli-error/error-message/definition-error-message.mjs.map +7 -0
- package/lib/mjs/cli-error/error-message/internal-error-message.mjs +16 -0
- package/lib/mjs/cli-error/error-message/internal-error-message.mjs.map +7 -0
- package/lib/mjs/cli-error/error-message/parse-error-message.mjs +40 -0
- package/lib/mjs/cli-error/error-message/parse-error-message.mjs.map +7 -0
- package/lib/mjs/cli-error/error-message/validation-error-message.mjs +60 -0
- package/lib/mjs/cli-error/error-message/validation-error-message.mjs.map +7 -0
- package/lib/mjs/coerce/coerce-methods.mjs +197 -2
- package/lib/mjs/coerce/coerce-methods.mjs.map +7 -1
- package/lib/mjs/coerce/string-to-array.mjs +17 -2
- package/lib/mjs/coerce/string-to-array.mjs.map +7 -1
- package/lib/mjs/coerce/string-to-primitive.mjs +73 -2
- package/lib/mjs/coerce/string-to-primitive.mjs.map +7 -1
- package/lib/mjs/coerce/string-to-set.mjs +17 -2
- package/lib/mjs/coerce/string-to-set.mjs.map +7 -1
- package/lib/mjs/definitions/define-arguments.mjs +10 -2
- package/lib/mjs/definitions/define-arguments.mjs.map +7 -1
- package/lib/mjs/definitions/define-cli.mjs +89 -2
- package/lib/mjs/definitions/define-cli.mjs.map +7 -1
- package/lib/mjs/definitions/define-options.mjs +10 -2
- package/lib/mjs/definitions/define-options.mjs.map +7 -1
- package/lib/mjs/definitions/define-subcommand.mjs +56 -2
- package/lib/mjs/definitions/define-subcommand.mjs.map +7 -1
- package/lib/mjs/definitions/validate-cli-definition.mjs +360 -2
- package/lib/mjs/definitions/validate-cli-definition.mjs.map +7 -1
- package/lib/mjs/help-message/format-arguments.mjs +48 -2
- package/lib/mjs/help-message/format-arguments.mjs.map +7 -1
- package/lib/mjs/help-message/format-options.mjs +50 -2
- package/lib/mjs/help-message/format-options.mjs.map +7 -1
- package/lib/mjs/help-message/format-subcommands.mjs +37 -2
- package/lib/mjs/help-message/format-subcommands.mjs.map +7 -1
- package/lib/mjs/help-message/generate-for-cli.mjs +71 -2
- package/lib/mjs/help-message/generate-for-cli.mjs.map +7 -1
- package/lib/mjs/help-message/generate-for-subcommand.mjs +23 -2
- package/lib/mjs/help-message/generate-for-subcommand.mjs.map +7 -1
- package/lib/mjs/help-message/print-help.mjs +14 -2
- package/lib/mjs/help-message/print-help.mjs.map +7 -1
- package/lib/mjs/help-message/set-defaults.mjs +29 -2
- package/lib/mjs/help-message/set-defaults.mjs.map +7 -1
- package/lib/mjs/help-message/styles.mjs +154 -2
- package/lib/mjs/help-message/styles.mjs.map +7 -1
- package/lib/mjs/help-message/terminal-markdown.mjs +121 -2
- package/lib/mjs/help-message/terminal-markdown.mjs.map +7 -1
- package/lib/mjs/index.mjs +52 -2
- package/lib/mjs/index.mjs.map +7 -1
- package/lib/mjs/markdown/generate-markdown.mjs +153 -2
- package/lib/mjs/markdown/generate-markdown.mjs.map +7 -1
- package/lib/mjs/metadata/arguments-metadata.mjs +26 -2
- package/lib/mjs/metadata/arguments-metadata.mjs.map +7 -1
- package/lib/mjs/metadata/cli-metadata.mjs +24 -2
- package/lib/mjs/metadata/cli-metadata.mjs.map +7 -1
- package/lib/mjs/metadata/options-metadata.mjs +35 -2
- package/lib/mjs/metadata/options-metadata.mjs.map +7 -1
- package/lib/mjs/metadata/subcommands-metadata.mjs +32 -2
- package/lib/mjs/metadata/subcommands-metadata.mjs.map +7 -1
- package/lib/mjs/parse/context/cli-context-builder.mjs +283 -2
- package/lib/mjs/parse/context/cli-context-builder.mjs.map +7 -1
- package/lib/mjs/parse/context/object-context-builder.mjs +62 -2
- package/lib/mjs/parse/context/object-context-builder.mjs.map +7 -1
- package/lib/mjs/parse/parser-utilities.mjs +108 -2
- package/lib/mjs/parse/parser-utilities.mjs.map +7 -1
- package/lib/mjs/parse/safe-parse.mjs +57 -2
- package/lib/mjs/parse/safe-parse.mjs.map +7 -1
- package/lib/mjs/parse/validation/validate-context.mjs +17 -2
- package/lib/mjs/parse/validation/validate-context.mjs.map +7 -1
- package/lib/mjs/parse/validation/validators/arguments.mjs +67 -2
- package/lib/mjs/parse/validation/validators/arguments.mjs.map +7 -1
- package/lib/mjs/parse/validation/validators/conflict.mjs +38 -2
- package/lib/mjs/parse/validation/validators/conflict.mjs.map +7 -1
- package/lib/mjs/parse/validation/validators/exclusive.mjs +39 -2
- package/lib/mjs/parse/validation/validators/exclusive.mjs.map +7 -1
- package/lib/mjs/parse/validation/validators/explicitly-passed.mjs +18 -2
- package/lib/mjs/parse/validation/validators/explicitly-passed.mjs.map +7 -1
- package/lib/mjs/parse/validation/validators/options.mjs +67 -2
- package/lib/mjs/parse/validation/validators/options.mjs.map +7 -1
- package/lib/mjs/parse/validation/validators/requires.mjs +43 -2
- package/lib/mjs/parse/validation/validators/requires.mjs.map +7 -1
- package/lib/mjs/utilities/parse-argv.mjs +61 -0
- package/lib/mjs/utilities/parse-argv.mjs.map +7 -0
- package/lib/mjs/utilities/schema-utilities.mjs +57 -0
- package/lib/mjs/utilities/schema-utilities.mjs.map +7 -0
- package/lib/mjs/utilities/utilities.mjs +122 -0
- package/lib/mjs/utilities/utilities.mjs.map +7 -0
- package/lib/{typescript → types}/autocomplete-scripts/bash-autocomplete-script.d.ts.map +1 -1
- package/lib/types/autocomplete-scripts/powershell-autocomplete-script.d.ts +15 -0
- package/lib/{typescript → types}/autocomplete-scripts/powershell-autocomplete-script.d.ts.map +1 -1
- package/lib/types/autocomplete-scripts/zsh-autocomplete-script.d.ts +4 -0
- package/lib/{typescript → types}/autocomplete-scripts/zsh-autocomplete-script.d.ts.map +1 -1
- package/lib/types/cli-error/cli-error.d.ts +152 -0
- package/lib/types/cli-error/cli-error.d.ts.map +1 -0
- package/lib/types/cli-error/error-cause.d.ts +5 -0
- package/lib/types/cli-error/error-cause.d.ts.map +1 -0
- package/lib/types/cli-error/error-code/definition-error-code.d.ts +5 -0
- package/lib/types/cli-error/error-code/definition-error-code.d.ts.map +1 -0
- package/lib/types/cli-error/error-code/internal-error-code.d.ts +5 -0
- package/lib/types/cli-error/error-code/internal-error-code.d.ts.map +1 -0
- package/lib/types/cli-error/error-code/parse-error-code.d.ts +5 -0
- package/lib/types/cli-error/error-code/parse-error-code.d.ts.map +1 -0
- package/lib/types/cli-error/error-code/validation-error-code.d.ts +5 -0
- package/lib/types/cli-error/error-code/validation-error-code.d.ts.map +1 -0
- package/lib/types/cli-error/error-message/definition-error-message.d.ts +3 -0
- package/lib/types/cli-error/error-message/definition-error-message.d.ts.map +1 -0
- package/lib/types/cli-error/error-message/internal-error-message.d.ts +3 -0
- package/lib/types/cli-error/error-message/internal-error-message.d.ts.map +1 -0
- package/lib/types/cli-error/error-message/parse-error-message.d.ts +3 -0
- package/lib/types/cli-error/error-message/parse-error-message.d.ts.map +1 -0
- package/lib/types/cli-error/error-message/validation-error-message.d.ts +3 -0
- package/lib/types/cli-error/error-message/validation-error-message.d.ts.map +1 -0
- package/lib/types/coerce/coerce-methods.d.ts +122 -0
- package/lib/types/coerce/coerce-methods.d.ts.map +1 -0
- package/lib/{typescript → types}/coerce/string-to-array.d.ts +2 -2
- package/lib/types/coerce/string-to-array.d.ts.map +1 -0
- package/lib/types/coerce/string-to-primitive.d.ts +21 -0
- package/lib/types/coerce/string-to-primitive.d.ts.map +1 -0
- package/lib/{typescript → types}/coerce/string-to-set.d.ts +2 -2
- package/lib/{typescript → types}/coerce/string-to-set.d.ts.map +1 -1
- package/lib/{typescript → types}/definitions/define-cli.d.ts +2 -6
- package/lib/types/definitions/define-cli.d.ts.map +1 -0
- package/lib/{typescript → types}/definitions/define-subcommand.d.ts +2 -4
- package/lib/types/definitions/define-subcommand.d.ts.map +1 -0
- package/lib/{typescript → types}/definitions/validate-cli-definition.d.ts +1 -1
- package/lib/types/definitions/validate-cli-definition.d.ts.map +1 -0
- package/lib/{typescript → types}/help-message/terminal-markdown.d.ts.map +1 -1
- package/lib/{typescript → types}/index.d.ts +7 -0
- package/lib/{typescript → types}/index.d.ts.map +1 -1
- package/lib/{typescript → types}/metadata/arguments-metadata.d.ts.map +1 -1
- package/lib/{typescript → types}/metadata/options-metadata.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/context/cli-context-builder.d.ts +1 -1
- package/lib/{typescript → types}/parse/context/cli-context-builder.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/context/object-context-builder.d.ts +1 -1
- package/lib/types/parse/context/object-context-builder.d.ts.map +1 -0
- package/lib/{typescript → types}/parse/parser-utilities.d.ts +9 -0
- package/lib/{typescript → types}/parse/parser-utilities.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/safe-parse.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/validation/validate-context.d.ts +1 -1
- package/lib/{typescript → types}/parse/validation/validate-context.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/validation/validators/arguments.d.ts +1 -1
- package/lib/{typescript → types}/parse/validation/validators/arguments.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/validation/validators/conflict.d.ts +3 -3
- package/lib/{typescript → types}/parse/validation/validators/conflict.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/validation/validators/exclusive.d.ts +3 -3
- package/lib/{typescript → types}/parse/validation/validators/exclusive.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/validation/validators/options.d.ts +1 -1
- package/lib/{typescript → types}/parse/validation/validators/options.d.ts.map +1 -1
- package/lib/{typescript → types}/parse/validation/validators/requires.d.ts +3 -3
- package/lib/{typescript → types}/parse/validation/validators/requires.d.ts.map +1 -1
- package/lib/{typescript → types}/types/definitions-types.d.ts +35 -4
- package/lib/types/types/definitions-types.d.ts.map +1 -0
- package/lib/types/types/error-types.d.ts +275 -0
- package/lib/types/types/error-types.d.ts.map +1 -0
- package/lib/types/types/types.d.ts +146 -0
- package/lib/types/types/types.d.ts.map +1 -0
- package/lib/{typescript → types}/types/utilities-types.d.ts +0 -2
- package/lib/{typescript → types}/types/utilities-types.d.ts.map +1 -1
- package/lib/types/utilities/parse-argv.d.ts +3 -0
- package/lib/types/utilities/parse-argv.d.ts.map +1 -0
- package/lib/types/utilities/schema-utilities.d.ts +15 -0
- package/lib/types/utilities/schema-utilities.d.ts.map +1 -0
- package/lib/{typescript → types/utilities}/utilities.d.ts +12 -15
- package/lib/types/utilities/utilities.d.ts.map +1 -0
- package/package.json +10 -9
- package/src/autocomplete-scripts/bash-autocomplete-script.ts +14 -12
- package/src/autocomplete-scripts/powershell-autocomplete-script.ts +67 -33
- package/src/autocomplete-scripts/zsh-autocomplete-script.ts +39 -31
- package/src/cli-error/cli-error.ts +44 -0
- package/src/cli-error/error-cause.ts +10 -0
- package/src/cli-error/error-code/definition-error-code.ts +21 -0
- package/src/cli-error/error-code/internal-error-code.ts +8 -0
- package/src/cli-error/error-code/parse-error-code.ts +16 -0
- package/src/cli-error/error-code/validation-error-code.ts +15 -0
- package/src/cli-error/error-message/definition-error-message.ts +144 -0
- package/src/cli-error/error-message/internal-error-message.ts +19 -0
- package/src/cli-error/error-message/parse-error-message.ts +76 -0
- package/src/cli-error/error-message/validation-error-message.ts +104 -0
- package/src/coerce/coerce-methods.ts +194 -39
- package/src/coerce/string-to-array.ts +2 -2
- package/src/coerce/string-to-primitive.ts +72 -13
- package/src/coerce/string-to-set.ts +2 -2
- package/src/definitions/define-arguments.ts +1 -1
- package/src/definitions/define-cli.ts +65 -30
- package/src/definitions/define-options.ts +1 -1
- package/src/definitions/define-subcommand.ts +47 -17
- package/src/definitions/validate-cli-definition.ts +287 -172
- package/src/help-message/format-arguments.ts +1 -1
- package/src/help-message/format-options.ts +1 -1
- package/src/help-message/format-subcommands.ts +1 -1
- package/src/help-message/generate-for-cli.ts +1 -1
- package/src/help-message/terminal-markdown.ts +3 -4
- package/src/index.ts +16 -0
- package/src/markdown/generate-markdown.ts +5 -4
- package/src/metadata/arguments-metadata.ts +2 -1
- package/src/metadata/options-metadata.ts +2 -1
- package/src/parse/context/cli-context-builder.ts +166 -39
- package/src/parse/context/object-context-builder.ts +37 -11
- package/src/parse/parser-utilities.ts +24 -10
- package/src/parse/safe-parse.ts +3 -6
- package/src/parse/validation/validate-context.ts +1 -1
- package/src/parse/validation/validators/arguments.ts +42 -14
- package/src/parse/validation/validators/conflict.ts +11 -20
- package/src/parse/validation/validators/exclusive.ts +16 -25
- package/src/parse/validation/validators/options.ts +40 -12
- package/src/parse/validation/validators/requires.ts +11 -20
- package/src/types/definitions-types.ts +36 -8
- package/src/types/error-types.ts +326 -0
- package/src/types/types.ts +100 -7
- package/src/types/utilities-types.ts +0 -10
- package/src/utilities/parse-argv.ts +79 -0
- package/src/utilities/schema-utilities.ts +72 -0
- package/src/{utilities.ts → utilities/utilities.ts} +25 -138
- package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs +0 -2
- package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs.map +0 -1
- package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs +0 -2
- package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs.map +0 -1
- package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs +0 -42
- package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs.map +0 -1
- package/lib/cjs/coerce/coerce-methods.cjs +0 -2
- package/lib/cjs/coerce/coerce-methods.cjs.map +0 -1
- package/lib/cjs/coerce/string-to-array.cjs +0 -2
- package/lib/cjs/coerce/string-to-array.cjs.map +0 -1
- package/lib/cjs/coerce/string-to-primitive.cjs +0 -2
- package/lib/cjs/coerce/string-to-primitive.cjs.map +0 -1
- package/lib/cjs/coerce/string-to-set.cjs +0 -2
- package/lib/cjs/coerce/string-to-set.cjs.map +0 -1
- package/lib/cjs/definitions/define-arguments.cjs +0 -2
- package/lib/cjs/definitions/define-arguments.cjs.map +0 -1
- package/lib/cjs/definitions/define-cli.cjs +0 -2
- package/lib/cjs/definitions/define-cli.cjs.map +0 -1
- package/lib/cjs/definitions/define-options.cjs +0 -2
- package/lib/cjs/definitions/define-options.cjs.map +0 -1
- package/lib/cjs/definitions/define-subcommand.cjs +0 -2
- package/lib/cjs/definitions/define-subcommand.cjs.map +0 -1
- package/lib/cjs/definitions/validate-cli-definition.cjs +0 -2
- package/lib/cjs/definitions/validate-cli-definition.cjs.map +0 -1
- package/lib/cjs/help-message/format-arguments.cjs +0 -2
- package/lib/cjs/help-message/format-arguments.cjs.map +0 -1
- package/lib/cjs/help-message/format-options.cjs +0 -2
- package/lib/cjs/help-message/format-options.cjs.map +0 -1
- package/lib/cjs/help-message/format-subcommands.cjs +0 -2
- package/lib/cjs/help-message/format-subcommands.cjs.map +0 -1
- package/lib/cjs/help-message/generate-for-cli.cjs +0 -2
- package/lib/cjs/help-message/generate-for-cli.cjs.map +0 -1
- package/lib/cjs/help-message/generate-for-subcommand.cjs +0 -2
- package/lib/cjs/help-message/generate-for-subcommand.cjs.map +0 -1
- package/lib/cjs/help-message/print-help.cjs +0 -2
- package/lib/cjs/help-message/print-help.cjs.map +0 -1
- package/lib/cjs/help-message/set-defaults.cjs +0 -2
- package/lib/cjs/help-message/set-defaults.cjs.map +0 -1
- package/lib/cjs/help-message/styles.cjs +0 -2
- package/lib/cjs/help-message/styles.cjs.map +0 -1
- package/lib/cjs/help-message/terminal-markdown.cjs +0 -2
- package/lib/cjs/help-message/terminal-markdown.cjs.map +0 -1
- package/lib/cjs/index.cjs +0 -2
- package/lib/cjs/index.cjs.map +0 -1
- package/lib/cjs/markdown/generate-markdown.cjs +0 -2
- package/lib/cjs/markdown/generate-markdown.cjs.map +0 -1
- package/lib/cjs/metadata/arguments-metadata.cjs +0 -2
- package/lib/cjs/metadata/arguments-metadata.cjs.map +0 -1
- package/lib/cjs/metadata/cli-metadata.cjs +0 -2
- package/lib/cjs/metadata/cli-metadata.cjs.map +0 -1
- package/lib/cjs/metadata/options-metadata.cjs +0 -2
- package/lib/cjs/metadata/options-metadata.cjs.map +0 -1
- package/lib/cjs/metadata/subcommands-metadata.cjs +0 -2
- package/lib/cjs/metadata/subcommands-metadata.cjs.map +0 -1
- package/lib/cjs/parse/context/cli-context-builder.cjs +0 -2
- package/lib/cjs/parse/context/cli-context-builder.cjs.map +0 -1
- package/lib/cjs/parse/context/object-context-builder.cjs +0 -2
- package/lib/cjs/parse/context/object-context-builder.cjs.map +0 -1
- package/lib/cjs/parse/parser-utilities.cjs +0 -2
- package/lib/cjs/parse/parser-utilities.cjs.map +0 -1
- package/lib/cjs/parse/safe-parse.cjs +0 -2
- package/lib/cjs/parse/safe-parse.cjs.map +0 -1
- package/lib/cjs/parse/validation/validate-context.cjs +0 -2
- package/lib/cjs/parse/validation/validate-context.cjs.map +0 -1
- package/lib/cjs/parse/validation/validators/arguments.cjs +0 -2
- package/lib/cjs/parse/validation/validators/arguments.cjs.map +0 -1
- package/lib/cjs/parse/validation/validators/conflict.cjs +0 -2
- package/lib/cjs/parse/validation/validators/conflict.cjs.map +0 -1
- package/lib/cjs/parse/validation/validators/exclusive.cjs +0 -2
- package/lib/cjs/parse/validation/validators/exclusive.cjs.map +0 -1
- package/lib/cjs/parse/validation/validators/explicitly-passed.cjs +0 -2
- package/lib/cjs/parse/validation/validators/explicitly-passed.cjs.map +0 -1
- package/lib/cjs/parse/validation/validators/options.cjs +0 -2
- package/lib/cjs/parse/validation/validators/options.cjs.map +0 -1
- package/lib/cjs/parse/validation/validators/requires.cjs +0 -2
- package/lib/cjs/parse/validation/validators/requires.cjs.map +0 -1
- package/lib/cjs/utilities.cjs +0 -2
- package/lib/cjs/utilities.cjs.map +0 -1
- package/lib/esm/utilities.js +0 -2
- package/lib/esm/utilities.js.map +0 -1
- package/lib/mjs/utilities.mjs +0 -2
- package/lib/mjs/utilities.mjs.map +0 -1
- package/lib/typescript/autocomplete-scripts/powershell-autocomplete-script.d.ts +0 -14
- package/lib/typescript/autocomplete-scripts/zsh-autocomplete-script.d.ts +0 -11
- package/lib/typescript/coerce/coerce-methods.d.ts +0 -20
- package/lib/typescript/coerce/coerce-methods.d.ts.map +0 -1
- package/lib/typescript/coerce/string-to-array.d.ts.map +0 -1
- package/lib/typescript/coerce/string-to-primitive.d.ts +0 -5
- package/lib/typescript/coerce/string-to-primitive.d.ts.map +0 -1
- package/lib/typescript/definitions/define-cli.d.ts.map +0 -1
- package/lib/typescript/definitions/define-subcommand.d.ts.map +0 -1
- package/lib/typescript/definitions/validate-cli-definition.d.ts.map +0 -1
- package/lib/typescript/parse/context/object-context-builder.d.ts.map +0 -1
- package/lib/typescript/types/definitions-types.d.ts.map +0 -1
- package/lib/typescript/types/types.d.ts +0 -61
- package/lib/typescript/types/types.d.ts.map +0 -1
- package/lib/typescript/utilities.d.ts.map +0 -1
- /package/lib/{typescript → types}/autocomplete-scripts/bash-autocomplete-script.d.ts +0 -0
- /package/lib/{typescript → types}/definitions/define-arguments.d.ts +0 -0
- /package/lib/{typescript → types}/definitions/define-arguments.d.ts.map +0 -0
- /package/lib/{typescript → types}/definitions/define-options.d.ts +0 -0
- /package/lib/{typescript → types}/definitions/define-options.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/format-arguments.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/format-arguments.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/format-options.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/format-options.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/format-subcommands.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/format-subcommands.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/generate-for-cli.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/generate-for-cli.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/generate-for-subcommand.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/generate-for-subcommand.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/print-help.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/print-help.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/set-defaults.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/set-defaults.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/styles.d.ts +0 -0
- /package/lib/{typescript → types}/help-message/styles.d.ts.map +0 -0
- /package/lib/{typescript → types}/help-message/terminal-markdown.d.ts +0 -0
- /package/lib/{typescript → types}/markdown/generate-markdown.d.ts +0 -0
- /package/lib/{typescript → types}/markdown/generate-markdown.d.ts.map +0 -0
- /package/lib/{typescript → types}/metadata/arguments-metadata.d.ts +0 -0
- /package/lib/{typescript → types}/metadata/cli-metadata.d.ts +0 -0
- /package/lib/{typescript → types}/metadata/cli-metadata.d.ts.map +0 -0
- /package/lib/{typescript → types}/metadata/options-metadata.d.ts +0 -0
- /package/lib/{typescript → types}/metadata/subcommands-metadata.d.ts +0 -0
- /package/lib/{typescript → types}/metadata/subcommands-metadata.d.ts.map +0 -0
- /package/lib/{typescript → types}/parse/safe-parse.d.ts +0 -0
- /package/lib/{typescript → types}/parse/validation/validators/explicitly-passed.d.ts +0 -0
- /package/lib/{typescript → types}/parse/validation/validators/explicitly-passed.d.ts.map +0 -0
- /package/lib/{typescript → types}/types/context-types.d.ts +0 -0
- /package/lib/{typescript → types}/types/context-types.d.ts.map +0 -0
- /package/lib/{typescript → types}/types/help-message-types.d.ts +0 -0
- /package/lib/{typescript → types}/types/help-message-types.d.ts.map +0 -0
- /package/lib/{typescript → types}/types/io-types.d.ts +0 -0
- /package/lib/{typescript → types}/types/io-types.d.ts.map +0 -0
- /package/lib/{typescript → types}/types/metadata-types.d.ts +0 -0
- /package/lib/{typescript → types}/types/metadata-types.d.ts.map +0 -0
- /package/lib/{typescript → types}/types/schema-types.d.ts +0 -0
- /package/lib/{typescript → types}/types/schema-types.d.ts.map +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/cli-error/error-message/internal-error-message.ts
|
|
2
|
+
import { InternalErrorCode } from "../error-code/internal-error-code.js";
|
|
3
|
+
function internalErrorMessage({ code, context }) {
|
|
4
|
+
if (code === InternalErrorCode.MissingPreparedTypes) {
|
|
5
|
+
return `internal error: missing prepared type for option "${context.name}" in ${context.commandKind} "${context.commandName}"`;
|
|
6
|
+
}
|
|
7
|
+
if (code === InternalErrorCode.CannotFindCliDefinition) {
|
|
8
|
+
return `internal error: cannot find cli definition "${context.cliName}"`;
|
|
9
|
+
}
|
|
10
|
+
const executiveCheck = code;
|
|
11
|
+
return executiveCheck;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
internalErrorMessage
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=internal-error-message.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli-error/error-message/internal-error-message.ts"],
|
|
4
|
+
"sourcesContent": ["import { InternalErrorCode } from \"../error-code/internal-error-code.ts\";\n\nimport type { CliErrorOptionByCause } from \"../../types/error-types.ts\";\n\nexport function internalErrorMessage({ code, context }: CliErrorOptionByCause<\"Internal\">) {\n if (code === InternalErrorCode.MissingPreparedTypes) {\n return (\n `internal error: missing prepared type ` +\n `for option \"${context.name}\" in ${context.commandKind} \"${context.commandName}\"`\n );\n }\n\n if (code === InternalErrorCode.CannotFindCliDefinition) {\n return `internal error: cannot find cli definition \"${context.cliName}\"`;\n }\n\n const executiveCheck: never = code;\n return executiveCheck;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,yBAAyB;AAI3B,SAAS,qBAAqB,EAAE,MAAM,QAAQ,GAAsC;AACzF,MAAI,SAAS,kBAAkB,sBAAsB;AACnD,WACE,qDACe,QAAQ,IAAI,QAAQ,QAAQ,WAAW,KAAK,QAAQ,WAAW;AAAA,EAElF;AAEA,MAAI,SAAS,kBAAkB,yBAAyB;AACtD,WAAO,+CAA+C,QAAQ,OAAO;AAAA,EACvE;AAEA,QAAM,iBAAwB;AAC9B,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/cli-error/error-message/parse-error-message.ts
|
|
2
|
+
import { ParseErrorCode } from "../error-code/parse-error-code.js";
|
|
3
|
+
function parseErrorMessage({ code, context }) {
|
|
4
|
+
if (code === ParseErrorCode.UnknownSubcommand) {
|
|
5
|
+
return `parsing error: unknown subcommand "${context.commandName}".`;
|
|
6
|
+
}
|
|
7
|
+
if (code === ParseErrorCode.CommandWithoutOptions) {
|
|
8
|
+
return `parsing error: the ${context.commandKind} "${context.commandName}" does not allow options, but received "${context.optionName}".`;
|
|
9
|
+
}
|
|
10
|
+
if (code === ParseErrorCode.UnknownOption) {
|
|
11
|
+
return `parsing error: unknown option "${context.optionName}" for the ${context.commandKind} "${context.commandName}".`;
|
|
12
|
+
}
|
|
13
|
+
if (code === ParseErrorCode.DuplicateOptionProvided) {
|
|
14
|
+
return `parsing error: duplicate option "${context.optionName}" provided for the ${context.commandKind} "${context.commandName}".`;
|
|
15
|
+
}
|
|
16
|
+
if (code === ParseErrorCode.InvalidNegationForNonBooleanOption) {
|
|
17
|
+
return `parsing error: option "${context.optionName}" cannot be negated because it is not a boolean option for the ${context.commandKind} "${context.commandName}".`;
|
|
18
|
+
}
|
|
19
|
+
if (code === ParseErrorCode.PositionalArgumentNotAllowed) {
|
|
20
|
+
return `parsing error: positional argument "${context.argumentName}" is not allowed for the ${context.commandKind} "${context.commandName}".`;
|
|
21
|
+
}
|
|
22
|
+
if (code === ParseErrorCode.MissingRequiredOption) {
|
|
23
|
+
return `parsing error: missing required option "${context.optionName}" for the ${context.commandKind} "${context.commandName}".`;
|
|
24
|
+
}
|
|
25
|
+
if (code === ParseErrorCode.MissingRequiredArgument) {
|
|
26
|
+
return `parsing error: missing required argument "${context.argumentName}" for the ${context.commandKind} "${context.commandName}".`;
|
|
27
|
+
}
|
|
28
|
+
if (code === ParseErrorCode.OptionMissingValue) {
|
|
29
|
+
return `parsing error: the option "${context.optionName}" for the ${context.commandKind} "${context.commandName}" expects a value but received none.`;
|
|
30
|
+
}
|
|
31
|
+
if (code === ParseErrorCode.FlagAssignedValue) {
|
|
32
|
+
return `parsing error: flag option "${context.flag}" in ${context.commandKind} "${context.commandName}" cannot be assigned a value using "=" (provided: "${context.value}").`;
|
|
33
|
+
}
|
|
34
|
+
const executiveCheck = code;
|
|
35
|
+
return executiveCheck;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
parseErrorMessage
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=parse-error-message.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli-error/error-message/parse-error-message.ts"],
|
|
4
|
+
"sourcesContent": ["import { ParseErrorCode } from \"../error-code/parse-error-code.ts\";\n\nimport type { CliErrorOptionByCause } from \"../../types/error-types.ts\";\n\nexport function parseErrorMessage({ code, context }: CliErrorOptionByCause<\"Parse\">) {\n if (code === ParseErrorCode.UnknownSubcommand) {\n return `parsing error: unknown subcommand \"${context.commandName}\".`;\n }\n\n if (code === ParseErrorCode.CommandWithoutOptions) {\n return (\n `parsing error: the ${context.commandKind} \"${context.commandName}\" ` +\n `does not allow options, but received \"${context.optionName}\".`\n );\n }\n\n if (code === ParseErrorCode.UnknownOption) {\n return (\n `parsing error: unknown option \"${context.optionName}\" ` +\n `for the ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ParseErrorCode.DuplicateOptionProvided) {\n return (\n `parsing error: duplicate option \"${context.optionName}\" ` +\n `provided for the ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ParseErrorCode.InvalidNegationForNonBooleanOption) {\n return (\n `parsing error: option \"${context.optionName}\" cannot be negated ` +\n `because it is not a boolean option for the ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ParseErrorCode.PositionalArgumentNotAllowed) {\n return (\n `parsing error: positional argument \"${context.argumentName}\" ` +\n `is not allowed for the ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ParseErrorCode.MissingRequiredOption) {\n return (\n `parsing error: missing required option \"${context.optionName}\" ` +\n `for the ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ParseErrorCode.MissingRequiredArgument) {\n return (\n `parsing error: missing required argument \"${context.argumentName}\" ` +\n `for the ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ParseErrorCode.OptionMissingValue) {\n return (\n `parsing error: the option \"${context.optionName}\" ` +\n `for the ${context.commandKind} \"${context.commandName}\" expects a value but received none.`\n );\n }\n\n if (code === ParseErrorCode.FlagAssignedValue) {\n return (\n `parsing error: ` +\n `flag option \"${context.flag}\" in ${context.commandKind} \"${context.commandName}\" ` +\n `cannot be assigned a value using \"=\" (provided: \"${context.value}\").`\n );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AW,KAAK,QAAQ,WAAW,sDAC3B,QAAQ,KAAK;AAAA,EAErE;AAEA,QAAM,iBAAwB;AAC9B,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/cli-error/error-message/validation-error-message.ts
|
|
2
|
+
import { prettifyError } from "../../utilities/schema-utilities.js";
|
|
3
|
+
import { ValidationErrorCode } from "../error-code/validation-error-code.js";
|
|
4
|
+
function validationErrorMessage({ code, context }) {
|
|
5
|
+
if (code === ValidationErrorCode.NoOptionsToValidate) {
|
|
6
|
+
return `validation error: trying to validate options for ${context.commandKind} "${context.commandName}" which does not define any.`;
|
|
7
|
+
}
|
|
8
|
+
if (code === ValidationErrorCode.NoArgumentsToValidate) {
|
|
9
|
+
return `validation error: trying to validate typed arguments for ${context.commandKind} "${context.commandName}" which does not define any.`;
|
|
10
|
+
}
|
|
11
|
+
if (code === ValidationErrorCode.UnknownOptionValidation) {
|
|
12
|
+
return `validation error: trying to validate a non-existent option "${context.optionName}" for ${context.commandKind} "${context.commandName}".`;
|
|
13
|
+
}
|
|
14
|
+
if (code === ValidationErrorCode.UnknownArgumentValidation) {
|
|
15
|
+
return `validation error: trying to validate a non-existent typed argument "${context.argumentName}" for ${context.commandKind} "${context.commandName}".`;
|
|
16
|
+
}
|
|
17
|
+
if (code === ValidationErrorCode.SchemaValidationFailed) {
|
|
18
|
+
return `validation error: the ${context.kind} "${context.name}" for ${context.commandKind} "${context.commandName}" failed to validate "${typeof context.inputValue === "string" ? context.inputValue : JSON.stringify(context.inputValue)}": ` + prettifyError(context.issues);
|
|
19
|
+
}
|
|
20
|
+
if (code === ValidationErrorCode.MutuallyExclusiveConflict) {
|
|
21
|
+
const parts = [];
|
|
22
|
+
if (context.conflictedOptions.length > 0) {
|
|
23
|
+
const formatted = context.conflictedOptions.map((o) => `"${o}"`).join(", ");
|
|
24
|
+
const s = context.conflictedOptions.length > 1 ? "s" : "";
|
|
25
|
+
parts.push(`option${s} ${formatted}`);
|
|
26
|
+
}
|
|
27
|
+
if (context.conflictedArguments.length > 0) {
|
|
28
|
+
const formatted = context.conflictedArguments.map((a) => `"${a}"`).join(", ");
|
|
29
|
+
const s = context.conflictedArguments.length > 1 ? "s" : "";
|
|
30
|
+
parts.push(`argument${s} ${formatted}`);
|
|
31
|
+
}
|
|
32
|
+
return `validation error: the ${context.kind} "${context.name}" cannot be used with the ${parts.join(" and ")} because they are mutually exclusive.`;
|
|
33
|
+
}
|
|
34
|
+
if (code === ValidationErrorCode.RequiredDependencyMissing) {
|
|
35
|
+
const parts = [];
|
|
36
|
+
if (context.missingOptions.length > 0) {
|
|
37
|
+
const formatted = context.missingOptions.map((o) => `"${o}"`).join(", ");
|
|
38
|
+
const s = context.missingOptions.length > 1 ? "s" : "";
|
|
39
|
+
parts.push(`option${s} ${formatted}`);
|
|
40
|
+
}
|
|
41
|
+
if (context.missingArguments.length > 0) {
|
|
42
|
+
const formatted = context.missingArguments.map((a) => `"${a}"`).join(", ");
|
|
43
|
+
const s = context.missingArguments.length > 1 ? "s" : "";
|
|
44
|
+
parts.push(`argument${s} ${formatted}`);
|
|
45
|
+
}
|
|
46
|
+
return `validation error: the ${context.kind} "${context.name}" cannot be used without the required "${parts.join(" and ")}".`;
|
|
47
|
+
}
|
|
48
|
+
if (code === ValidationErrorCode.AsyncSchemaNotSupported) {
|
|
49
|
+
return `validation error: cannot validate async schema: received ${typeof context.value === "string" ? context.value : JSON.stringify(context.value)}`;
|
|
50
|
+
}
|
|
51
|
+
if (code === ValidationErrorCode.CoercionFailed) {
|
|
52
|
+
return `validation error: failed to coerce the value "${typeof context.providedValue === "string" ? context.providedValue : JSON.stringify(context.providedValue)}" of type "${typeof context.providedValue}" to type "${context.coerceToType}".`;
|
|
53
|
+
}
|
|
54
|
+
const executiveCheck = code;
|
|
55
|
+
return executiveCheck;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
validationErrorMessage
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=validation-error-message.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli-error/error-message/validation-error-message.ts"],
|
|
4
|
+
"sourcesContent": ["import { prettifyError } from \"../../utilities/schema-utilities.ts\";\nimport { ValidationErrorCode } from \"../error-code/validation-error-code.ts\";\n\nimport type { CliErrorOptionByCause } from \"../../types/error-types.ts\";\n\nexport function validationErrorMessage({ code, context }: CliErrorOptionByCause<\"Validation\">) {\n if (code === ValidationErrorCode.NoOptionsToValidate) {\n return (\n `validation error: trying to validate options ` +\n `for ${context.commandKind} \"${context.commandName}\" which does not define any.`\n );\n }\n\n if (code === ValidationErrorCode.NoArgumentsToValidate) {\n return (\n `validation error: trying to validate typed arguments ` +\n `for ${context.commandKind} \"${context.commandName}\" which does not define any.`\n );\n }\n\n if (code === ValidationErrorCode.UnknownOptionValidation) {\n return (\n `validation error: trying to validate a non-existent option \"${context.optionName}\" ` +\n `for ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ValidationErrorCode.UnknownArgumentValidation) {\n return (\n `validation error: trying to validate a non-existent typed argument \"${context.argumentName}\" ` +\n `for ${context.commandKind} \"${context.commandName}\".`\n );\n }\n\n if (code === ValidationErrorCode.SchemaValidationFailed) {\n return (\n `validation error: ` +\n `the ${context.kind} \"${context.name}\" for ${context.commandKind} \"${context.commandName}\" failed to validate ` +\n `\"${typeof context.inputValue === \"string\" ? context.inputValue : JSON.stringify(context.inputValue)}\": ` +\n prettifyError(context.issues)\n );\n }\n\n if (code === ValidationErrorCode.MutuallyExclusiveConflict) {\n const parts: string[] = [];\n\n if (context.conflictedOptions.length > 0) {\n const formatted = context.conflictedOptions.map(o => `\"${o}\"`).join(\", \");\n const s = context.conflictedOptions.length > 1 ? \"s\" : \"\";\n parts.push(`option${s} ${formatted}`);\n }\n\n if (context.conflictedArguments.length > 0) {\n const formatted = context.conflictedArguments.map(a => `\"${a}\"`).join(\", \");\n const s = context.conflictedArguments.length > 1 ? \"s\" : \"\";\n parts.push(`argument${s} ${formatted}`);\n }\n\n return (\n `validation error: the ${context.kind} \"${context.name}\" ` +\n `cannot be used with the ${parts.join(\" and \")} because they are mutually exclusive.`\n );\n }\n\n if (code === ValidationErrorCode.RequiredDependencyMissing) {\n const parts: string[] = [];\n\n if (context.missingOptions.length > 0) {\n const formatted = context.missingOptions.map(o => `\"${o}\"`).join(\", \");\n const s = context.missingOptions.length > 1 ? \"s\" : \"\";\n parts.push(`option${s} ${formatted}`);\n }\n\n if (context.missingArguments.length > 0) {\n const formatted = context.missingArguments.map(a => `\"${a}\"`).join(\", \");\n const s = context.missingArguments.length > 1 ? \"s\" : \"\";\n parts.push(`argument${s} ${formatted}`);\n }\n\n return (\n `validation error: the ${context.kind} \"${context.name}\" ` +\n `cannot be used without the required \"${parts.join(\" and \")}\".`\n );\n }\n\n if (code === ValidationErrorCode.AsyncSchemaNotSupported) {\n return (\n `validation error: cannot validate async schema: ` +\n `received ${typeof context.value === \"string\" ? context.value : JSON.stringify(context.value)}`\n );\n }\n\n if (code === ValidationErrorCode.CoercionFailed) {\n return (\n `validation error: ` +\n `failed to coerce the value ` +\n `\"${typeof context.providedValue === \"string\" ? context.providedValue : JSON.stringify(context.providedValue)}\" ` +\n `of type \"${typeof context.providedValue}\" to type \"${context.coerceToType}\".`\n );\n }\n\n const executiveCheck: never = code;\n return executiveCheck;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AAI7B,SAAS,uBAAuB,EAAE,MAAM,QAAQ,GAAwC;AAC7F,MAAI,SAAS,oBAAoB,qBAAqB;AACpD,WACE,oDACO,QAAQ,WAAW,KAAK,QAAQ,WAAW;AAAA,EAEtD;AAEA,MAAI,SAAS,oBAAoB,uBAAuB;AACtD,WACE,4DACO,QAAQ,WAAW,KAAK,QAAQ,WAAW;AAAA,EAEtD;AAEA,MAAI,SAA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K,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI;AACrE,YAAM,IAAI,QAAQ,eAAe,SAAS,IAAI,MAAM;AACpD,YAAM,KAAK,SAAS,CAAC,IAAI,SAAS,EAAE;AAAA,IACtC;AAEA,QAAI,QAAQ,iBAAiB,SAAS,GAAG;AACvC,YAAM,YAAY,QAAQ,iBAAiB,IAAI,OAAK,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI;AACvE,YAAM,IAAI,QAAQ,iBAAiB,SAAS,IAAI,MAAM;AACtD,YAAM,KAAK,WAAW,CAAC,IAAI,SAAS,EAAE;AAAA,IACxC;AAEA,WACE,yBAAyB,QAAQ,IAAI,KAAK,QAAQ,IAAI,0CACd,MAAM,KAAK,OAAO,CAAC;AAAA,EAE/D;AAEA,MAAI,SAAS,oBAAoB,yBAAyB;AACxD,WACE,4DACY,OAAO,QAAQ,UAAU,WAAW,QAAQ,QAAQ,KAAK,UAAU,QAAQ,KAAK,CAAC;AAAA,EAEjG;AAEA,MAAI,SAAS,oBAAoB,gBAAgB;AAC/C,WACE,iDAEI,OAAO,QAAQ,kBAAkB,WAAW,QAAQ,gBAAgB,KAAK,UAAU,QAAQ,aAAa,CAAC,cACjG,OAAO,QAAQ,aAAa,cAAc,QAAQ,YAAY;AAAA,EAE9E;AAEA,QAAM,iBAAwB;AAC9B,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,197 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/coerce/coerce-methods.ts
|
|
2
|
+
import { walkObject } from "../utilities/utilities.js";
|
|
3
|
+
import { stringToBooleanArray, stringToNumberArray, stringToStringArray } from "./string-to-array.js";
|
|
4
|
+
import { stringToBigint, stringToBoolean, stringToNumber } from "./string-to-primitive.js";
|
|
5
|
+
import { stringToBooleanSet, stringToNumberSet, stringToStringSet } from "./string-to-set.js";
|
|
6
|
+
var string = (terminalInput) => terminalInput;
|
|
7
|
+
var number = (terminalInput) => stringToNumber(terminalInput);
|
|
8
|
+
var bigint = (terminalInput) => stringToBigint(terminalInput);
|
|
9
|
+
var json = (terminalInput) => JSON.parse(terminalInput);
|
|
10
|
+
var boolean = (terminalInput) => stringToBoolean(terminalInput);
|
|
11
|
+
boolean.type = "boolean";
|
|
12
|
+
var stringArray = (separator) => {
|
|
13
|
+
return (terminalInput) => stringToStringArray(terminalInput, separator);
|
|
14
|
+
};
|
|
15
|
+
var numberArray = (separator) => {
|
|
16
|
+
return (terminalInput) => stringToNumberArray(terminalInput, separator);
|
|
17
|
+
};
|
|
18
|
+
var booleanArray = (separator) => {
|
|
19
|
+
return (terminalInput) => stringToBooleanArray(terminalInput, separator);
|
|
20
|
+
};
|
|
21
|
+
var stringSet = (separator) => {
|
|
22
|
+
return (terminalInput) => stringToStringSet(terminalInput, separator);
|
|
23
|
+
};
|
|
24
|
+
var numberSet = (separator) => {
|
|
25
|
+
return (terminalInput) => stringToNumberSet(terminalInput, separator);
|
|
26
|
+
};
|
|
27
|
+
var booleanSet = (separator) => {
|
|
28
|
+
return (terminalInput) => stringToBooleanSet(terminalInput, separator);
|
|
29
|
+
};
|
|
30
|
+
var object = (options = {}) => {
|
|
31
|
+
const coerceMethod = (terminalInput) => {
|
|
32
|
+
const object2 = JSON.parse(terminalInput);
|
|
33
|
+
if (!options.coerceBoolean && !options.coerceNumber && !options.coerceBigint && !options.coerceDate) {
|
|
34
|
+
return object2;
|
|
35
|
+
}
|
|
36
|
+
walkObject(object2, (_, value, path) => {
|
|
37
|
+
if (typeof value !== "string") return value;
|
|
38
|
+
const shouldCoerce = (boolOrArray) => {
|
|
39
|
+
if (!boolOrArray) return false;
|
|
40
|
+
if (typeof boolOrArray === "boolean") return boolOrArray;
|
|
41
|
+
return boolOrArray.includes(path);
|
|
42
|
+
};
|
|
43
|
+
if (shouldCoerce(options.coerceBoolean)) {
|
|
44
|
+
try {
|
|
45
|
+
return stringToBoolean(value);
|
|
46
|
+
} catch {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (shouldCoerce(options.coerceNumber)) {
|
|
51
|
+
try {
|
|
52
|
+
return stringToNumber(value);
|
|
53
|
+
} catch {
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (shouldCoerce(options.coerceBigint)) {
|
|
58
|
+
try {
|
|
59
|
+
return BigInt(value);
|
|
60
|
+
} catch {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (shouldCoerce(options.coerceDate)) {
|
|
65
|
+
try {
|
|
66
|
+
return new Date(value);
|
|
67
|
+
} catch {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
});
|
|
73
|
+
return object2;
|
|
74
|
+
};
|
|
75
|
+
return coerceMethod;
|
|
76
|
+
};
|
|
77
|
+
var coerce = {
|
|
78
|
+
/**
|
|
79
|
+
* Since the terminal input is a string, this method does nothing.
|
|
80
|
+
*
|
|
81
|
+
* @since 2.0.0
|
|
82
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
83
|
+
*/
|
|
84
|
+
string,
|
|
85
|
+
/**
|
|
86
|
+
* Coerces a string matching `"true"` or `"false"` (case-insensitive) to a boolean value.
|
|
87
|
+
*
|
|
88
|
+
* @since 2.0.0
|
|
89
|
+
* @throws {CliError} If input is not a valid boolean string.
|
|
90
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
91
|
+
*/
|
|
92
|
+
boolean,
|
|
93
|
+
/**
|
|
94
|
+
* Coerces a string matching a number to a number value.
|
|
95
|
+
*
|
|
96
|
+
* @since 2.0.0
|
|
97
|
+
* @throws {CliError} If input is empty or not a valid number.
|
|
98
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
99
|
+
*/
|
|
100
|
+
number,
|
|
101
|
+
/**
|
|
102
|
+
* Coerces a string matching a number to a bigint value.
|
|
103
|
+
*
|
|
104
|
+
* @since 2.0.0
|
|
105
|
+
* @throws {CliError} If input is empty or not a valid bigint.
|
|
106
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
107
|
+
*/
|
|
108
|
+
bigint,
|
|
109
|
+
/**
|
|
110
|
+
* Coerces a JSON string into a JavaScript object, optionally converting certain string values into native types such
|
|
111
|
+
* as booleans, numbers, bigints, or dates.
|
|
112
|
+
*
|
|
113
|
+
* Each coercion option attempts conversion and silently falls back to the original string if the value cannot be
|
|
114
|
+
* converted.
|
|
115
|
+
*
|
|
116
|
+
* @since 2.0.0
|
|
117
|
+
* @throws {SyntaxError} If input is not a valid JSON string.
|
|
118
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/README.md##structured-object-options}
|
|
119
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
120
|
+
*/
|
|
121
|
+
object,
|
|
122
|
+
/**
|
|
123
|
+
* Converts a string to an array of strings by splitting it on the specified separator.
|
|
124
|
+
*
|
|
125
|
+
* @since 2.0.0
|
|
126
|
+
* @param separator - The separator to use to split the string.`
|
|
127
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
128
|
+
*/
|
|
129
|
+
stringArray,
|
|
130
|
+
/**
|
|
131
|
+
* Converts a string to an array of numbers by splitting it on the specified separator.
|
|
132
|
+
*
|
|
133
|
+
* Items that match the number regex will be converted to numbers.
|
|
134
|
+
*
|
|
135
|
+
* @since 2.0.0
|
|
136
|
+
* @param separator - The separator to use to split the string.`
|
|
137
|
+
* @throws {CliError} - When an item cannot be converted to a number
|
|
138
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
139
|
+
*/
|
|
140
|
+
numberArray,
|
|
141
|
+
/**
|
|
142
|
+
* Converts a string to an array of booleans by splitting it on the specified separator.
|
|
143
|
+
*
|
|
144
|
+
* Items that match `"true"` or `"false"` (case-insensitive) will be converted to booleans.
|
|
145
|
+
*
|
|
146
|
+
* @since 2.0.0
|
|
147
|
+
* @param separator - The separator to use to split the string.`
|
|
148
|
+
* @throws {CliError} - When an item cannot be converted to a boolean
|
|
149
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
150
|
+
*/
|
|
151
|
+
booleanArray,
|
|
152
|
+
/**
|
|
153
|
+
* Converts a string to a set of strings by splitting it on the specified separator.
|
|
154
|
+
*
|
|
155
|
+
* Items that match the number regex will be converted to numbers.
|
|
156
|
+
*
|
|
157
|
+
* @since 2.0.0
|
|
158
|
+
* @param separator - The separator to use to split the string.`
|
|
159
|
+
* @throws {CliError} - When an item cannot be converted to a number
|
|
160
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
161
|
+
*/
|
|
162
|
+
stringSet,
|
|
163
|
+
/**
|
|
164
|
+
* Converts a string to a set of numbers by splitting it on the specified separator.
|
|
165
|
+
*
|
|
166
|
+
* Items that match the number regex will be converted to numbers.
|
|
167
|
+
*
|
|
168
|
+
* @since 2.0.0
|
|
169
|
+
* @param separator - The separator to use to split the string.
|
|
170
|
+
* @throws {CliError} - When an item cannot be converted to a number
|
|
171
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
172
|
+
*/
|
|
173
|
+
numberSet,
|
|
174
|
+
/**
|
|
175
|
+
* Converts a string to a set of booleans by splitting it on the specified separator.
|
|
176
|
+
*
|
|
177
|
+
* Items that match `"true"` or `"false"` (case-insensitive) will be converted to booleans.
|
|
178
|
+
*
|
|
179
|
+
* @since 2.0.0
|
|
180
|
+
* @param separator - The separator to use to split the string.
|
|
181
|
+
* @throws {CliError} - When an item cannot be converted to a boolean
|
|
182
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
183
|
+
*/
|
|
184
|
+
booleanSet,
|
|
185
|
+
/**
|
|
186
|
+
* Parses a JSON string into a JavaScript object.
|
|
187
|
+
*
|
|
188
|
+
* @since 2.0.0
|
|
189
|
+
* @throws {SyntaxError} If input is not a valid JSON string.
|
|
190
|
+
* @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}
|
|
191
|
+
*/
|
|
192
|
+
json
|
|
193
|
+
};
|
|
194
|
+
export {
|
|
195
|
+
coerce
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=coerce-methods.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/coerce/coerce-methods.ts"],
|
|
4
|
+
"sourcesContent": ["import { walkObject } from \"../utilities/utilities.ts\";\nimport { stringToBooleanArray, stringToNumberArray, stringToStringArray } from \"./string-to-array.ts\";\nimport { stringToBigint, stringToBoolean, stringToNumber } from \"./string-to-primitive.ts\";\nimport { stringToBooleanSet, stringToNumberSet, stringToStringSet } from \"./string-to-set.ts\";\n\nimport type { ObjectCoerceMethodOptions } from \"../types/types.ts\";\n\nconst string = <T extends string | undefined>(terminalInput: string): T => terminalInput as T;\nconst number = <T extends number | undefined>(terminalInput: string): T => stringToNumber(terminalInput) as T;\nconst bigint = <T extends bigint | undefined>(terminalInput: string): T => stringToBigint(terminalInput) as T;\nconst json = <T>(terminalInput: string): T => JSON.parse(terminalInput) as T;\nconst boolean = <T extends boolean | undefined>(terminalInput: string): T => stringToBoolean(terminalInput) as T;\nboolean.type = \"boolean\";\n\nconst stringArray = (separator: string) => {\n return <T extends string[] | undefined>(terminalInput: string): T =>\n stringToStringArray(terminalInput, separator) as T;\n};\n\nconst numberArray = (separator: string) => {\n return <T extends number[] | undefined>(terminalInput: string): T =>\n stringToNumberArray(terminalInput, separator) as T;\n};\n\nconst booleanArray = (separator: string) => {\n return <T extends boolean[] | undefined>(terminalInput: string): T =>\n stringToBooleanArray(terminalInput, separator) as T;\n};\n\nconst stringSet = (separator: string) => {\n return <T extends Set<string> | undefined>(terminalInput: string): T =>\n stringToStringSet(terminalInput, separator) as T;\n};\n\nconst numberSet = (separator: string) => {\n return <T extends Set<number> | undefined>(terminalInput: string): T =>\n stringToNumberSet(terminalInput, separator) as T;\n};\n\nconst booleanSet = (separator: string) => {\n return <T extends Set<boolean> | undefined>(terminalInput: string): T =>\n stringToBooleanSet(terminalInput, separator) as T;\n};\n\nconst object = (options: ObjectCoerceMethodOptions = {}) => {\n const coerceMethod = <T extends Record<string, unknown> | undefined>(terminalInput: string): T => {\n const object = JSON.parse(terminalInput) as T;\n\n if (!options.coerceBoolean && !options.coerceNumber && !options.coerceBigint && !options.coerceDate) {\n return object;\n }\n\n walkObject(object!, (_, value, path) => {\n if (typeof value !== \"string\") return value;\n\n const shouldCoerce = (boolOrArray: boolean | string[] | undefined) => {\n if (!boolOrArray) return false;\n if (typeof boolOrArray === \"boolean\") return boolOrArray;\n return boolOrArray.includes(path);\n };\n\n if (shouldCoerce(options.coerceBoolean)) {\n try {\n return stringToBoolean(value);\n } catch {\n return value;\n }\n }\n\n if (shouldCoerce(options.coerceNumber)) {\n try {\n return stringToNumber(value);\n } catch {\n return value;\n }\n }\n\n if (shouldCoerce(options.coerceBigint)) {\n try {\n return BigInt(value);\n } catch {\n return value;\n }\n }\n\n if (shouldCoerce(options.coerceDate)) {\n try {\n return new Date(value);\n } catch {\n return value;\n }\n }\n\n return value;\n });\n\n return object;\n };\n\n return coerceMethod;\n};\n\nexport const coerce = {\n /**\n * Since the terminal input is a string, this method does nothing.\n *\n * @since 2.0.0\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n string,\n\n /**\n * Coerces a string matching `\"true\"` or `\"false\"` (case-insensitive) to a boolean value.\n *\n * @since 2.0.0\n * @throws {CliError} If input is not a valid boolean string.\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n boolean,\n\n /**\n * Coerces a string matching a number to a number value.\n *\n * @since 2.0.0\n * @throws {CliError} If input is empty or not a valid number.\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n number,\n\n /**\n * Coerces a string matching a number to a bigint value.\n *\n * @since 2.0.0\n * @throws {CliError} If input is empty or not a valid bigint.\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n bigint,\n\n /**\n * Coerces a JSON string into a JavaScript object, optionally converting certain string values into native types such\n * as booleans, numbers, bigints, or dates.\n *\n * Each coercion option attempts conversion and silently falls back to the original string if the value cannot be\n * converted.\n *\n * @since 2.0.0\n * @throws {SyntaxError} If input is not a valid JSON string.\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/README.md##structured-object-options}\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n object,\n\n /**\n * Converts a string to an array of strings by splitting it on the specified separator.\n *\n * @since 2.0.0\n * @param separator - The separator to use to split the string.`\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n stringArray,\n\n /**\n * Converts a string to an array of numbers by splitting it on the specified separator.\n *\n * Items that match the number regex will be converted to numbers.\n *\n * @since 2.0.0\n * @param separator - The separator to use to split the string.`\n * @throws {CliError} - When an item cannot be converted to a number\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n numberArray,\n\n /**\n * Converts a string to an array of booleans by splitting it on the specified separator.\n *\n * Items that match `\"true\"` or `\"false\"` (case-insensitive) will be converted to booleans.\n *\n * @since 2.0.0\n * @param separator - The separator to use to split the string.`\n * @throws {CliError} - When an item cannot be converted to a boolean\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n booleanArray,\n\n /**\n * Converts a string to a set of strings by splitting it on the specified separator.\n *\n * Items that match the number regex will be converted to numbers.\n *\n * @since 2.0.0\n * @param separator - The separator to use to split the string.`\n * @throws {CliError} - When an item cannot be converted to a number\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n stringSet,\n\n /**\n * Converts a string to a set of numbers by splitting it on the specified separator.\n *\n * Items that match the number regex will be converted to numbers.\n *\n * @since 2.0.0\n * @param separator - The separator to use to split the string.\n * @throws {CliError} - When an item cannot be converted to a number\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n numberSet,\n\n /**\n * Converts a string to a set of booleans by splitting it on the specified separator.\n *\n * Items that match `\"true\"` or `\"false\"` (case-insensitive) will be converted to booleans.\n *\n * @since 2.0.0\n * @param separator - The separator to use to split the string.\n * @throws {CliError} - When an item cannot be converted to a boolean\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n booleanSet,\n\n /**\n * Parses a JSON string into a JavaScript object.\n *\n * @since 2.0.0\n * @throws {SyntaxError} If input is not a valid JSON string.\n * @see {@link https://github.com/alabsi91/zod-args-parser/blob/main/docs/api-reference.md#coerce-helpers}\n */\n json,\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,qBAAqB,2BAA2B;AAC/E,SAAS,gBAAgB,iBAAiB,sBAAsB;AAChE,SAAS,oBAAoB,mBAAmB,yBAAyB;AAIzE,IAAM,SAAS,CAA+B,kBAA6B;AAC3E,IAAM,SAAS,CAA+B,kBAA6B,eAAe,aAAa;AACvG,IAAM,SAAS,CAA+B,kBAA6B,eAAe,aAAa;AACvG,IAAM,OAAO,CAAI,kBAA6B,KAAK,MAAM,aA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2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/coerce/string-to-array.ts
|
|
2
|
+
import { stringToBoolean, stringToNumber } from "./string-to-primitive.js";
|
|
3
|
+
function stringToStringArray(stringValue, separator = ",") {
|
|
4
|
+
return stringValue.split(separator).map((s) => s.trim()).filter(Boolean);
|
|
5
|
+
}
|
|
6
|
+
function stringToNumberArray(stringValue, separator = ",") {
|
|
7
|
+
return stringToStringArray(stringValue, separator).map((element) => stringToNumber(element));
|
|
8
|
+
}
|
|
9
|
+
function stringToBooleanArray(stringValue, separator = ",") {
|
|
10
|
+
return stringToStringArray(stringValue, separator).map((element) => stringToBoolean(element));
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
stringToBooleanArray,
|
|
14
|
+
stringToNumberArray,
|
|
15
|
+
stringToStringArray
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=string-to-array.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/coerce/string-to-array.ts"],
|
|
4
|
+
"sourcesContent": ["import { stringToBoolean, stringToNumber } from \"./string-to-primitive.ts\";\n\nexport function stringToStringArray(stringValue: string, separator: string = \",\"): string[] {\n return stringValue\n .split(separator)\n .map(s => s.trim())\n .filter(Boolean);\n}\n\n/** @throws {CliError} - Because of `stringToNumber` */\nexport function stringToNumberArray(stringValue: string, separator: string = \",\"): number[] {\n return stringToStringArray(stringValue, separator).map(element => stringToNumber(element));\n}\n\n/** @throws {CliError} - Because of `stringToBoolean` */\nexport function stringToBooleanArray(stringValue: string, separator: string = \",\"): boolean[] {\n return stringToStringArray(stringValue, separator).map(element => stringToBoolean(element));\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB,sBAAsB;AAEzC,SAAS,oBAAoB,aAAqB,YAAoB,KAAe;AAC1F,SAAO,YACJ,MAAM,SAAS,EACf,IAAI,OAAK,EAAE,KAAK,CAAC,EACjB,OAAO,OAAO;AACnB;AAGO,SAAS,oBAAoB,aAAqB,YAAoB,KAAe;AAC1F,SAAO,oBAAoB,aAAa,SAAS,EAAE,IAAI,aAAW,eAAe,OAAO,CAAC;AAC3F;AAGO,SAAS,qBAAqB,aAAqB,YAAoB,KAAgB;AAC5F,SAAO,oBAAoB,aAAa,SAAS,EAAE,IAAI,aAAW,gBAAgB,OAAO,CAAC;AAC5F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/coerce/string-to-primitive.ts
|
|
2
|
+
import { CliError } from "../cli-error/cli-error.js";
|
|
3
|
+
import { ErrorCause } from "../cli-error/error-cause.js";
|
|
4
|
+
import { ValidationErrorCode } from "../cli-error/error-code/validation-error-code.js";
|
|
5
|
+
function stringToBoolean(string) {
|
|
6
|
+
if (string.toLowerCase() === "true") {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (string.toLowerCase() === "false") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
throw new CliError({
|
|
13
|
+
cause: ErrorCause.Validation,
|
|
14
|
+
code: ValidationErrorCode.CoercionFailed,
|
|
15
|
+
context: { coerceToType: "boolean", providedValue: string }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function stringToNumber(value) {
|
|
19
|
+
const input = value.trim();
|
|
20
|
+
if (!/^[-+]?[0-9]+(?:\.[0-9]+)?$/.test(input)) {
|
|
21
|
+
throw new CliError({
|
|
22
|
+
cause: ErrorCause.Validation,
|
|
23
|
+
code: ValidationErrorCode.CoercionFailed,
|
|
24
|
+
context: { coerceToType: "number", providedValue: value }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const number = Number(input);
|
|
28
|
+
if (!Number.isFinite(number)) {
|
|
29
|
+
throw new CliError({
|
|
30
|
+
cause: ErrorCause.Validation,
|
|
31
|
+
code: ValidationErrorCode.CoercionFailed,
|
|
32
|
+
context: { coerceToType: "number", providedValue: value }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return number;
|
|
36
|
+
}
|
|
37
|
+
function stringToBigint(value) {
|
|
38
|
+
const input = value.trim();
|
|
39
|
+
if (!/^[+-]?[0-9]+$/.test(input)) {
|
|
40
|
+
throw new CliError({
|
|
41
|
+
cause: ErrorCause.Validation,
|
|
42
|
+
code: ValidationErrorCode.CoercionFailed,
|
|
43
|
+
context: { coerceToType: "bigint", providedValue: value }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
return BigInt(input);
|
|
48
|
+
} catch {
|
|
49
|
+
throw new CliError({
|
|
50
|
+
cause: ErrorCause.Validation,
|
|
51
|
+
code: ValidationErrorCode.CoercionFailed,
|
|
52
|
+
context: { coerceToType: "bigint", providedValue: value }
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function stringToDate(value) {
|
|
57
|
+
const date = new Date(value);
|
|
58
|
+
if (Number.isNaN(date.getTime())) {
|
|
59
|
+
throw new CliError({
|
|
60
|
+
cause: ErrorCause.Validation,
|
|
61
|
+
code: ValidationErrorCode.CoercionFailed,
|
|
62
|
+
context: { coerceToType: "date", providedValue: value }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return date;
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
stringToBigint,
|
|
69
|
+
stringToBoolean,
|
|
70
|
+
stringToDate,
|
|
71
|
+
stringToNumber
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=string-to-primitive.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/coerce/string-to-primitive.ts"],
|
|
4
|
+
"sourcesContent": ["import { CliError } from \"../cli-error/cli-error.ts\";\nimport { ErrorCause } from \"../cli-error/error-cause.ts\";\nimport { ValidationErrorCode } from \"../cli-error/error-code/validation-error-code.ts\";\n\n/** @throws {CliError} */\nexport function stringToBoolean(string: string): boolean {\n if (string.toLowerCase() === \"true\") {\n return true;\n }\n\n if (string.toLowerCase() === \"false\") {\n return false;\n }\n\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.CoercionFailed,\n context: { coerceToType: \"boolean\", providedValue: string },\n });\n}\n\n/**\n * Converts a string to a finite number.\n *\n * @throws {CliError} If input is empty, invalid, or not a finite number.\n */\nexport function stringToNumber(value: string): number {\n const input = value.trim();\n if (!/^[-+]?[0-9]+(?:\\.[0-9]+)?$/.test(input)) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.CoercionFailed,\n context: { coerceToType: \"number\", providedValue: value },\n });\n }\n\n const number = Number(input);\n if (!Number.isFinite(number)) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.CoercionFailed,\n context: { coerceToType: \"number\", providedValue: value },\n });\n }\n\n return number;\n}\n\n/**\n * Converts a string to a bigint.\n *\n * @throws {CliError} If input is empty or not a valid bigint.\n */\nexport function stringToBigint(value: string): bigint {\n const input = value.trim();\n if (!/^[+-]?[0-9]+$/.test(input)) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.CoercionFailed,\n context: { coerceToType: \"bigint\", providedValue: value },\n });\n }\n\n try {\n return BigInt(input);\n } catch {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.CoercionFailed,\n context: { coerceToType: \"bigint\", providedValue: value },\n });\n }\n}\n\n/**\n * Converts a string to a valid Date object.\n *\n * @throws {CliError} If input is not a valid date string.\n */\nexport function stringToDate(value: string): Date {\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.CoercionFailed,\n context: { coerceToType: \"date\", providedValue: value },\n });\n }\n return date;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,gB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A,MAC1B,SAAS,EAAE,cAAc,UAAU,eAAe,MAAM;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;AAOO,SAAS,aAAa,OAAqB;AAChD,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG;AAChC,UAAM,IAAI,SAAS;AAAA,MACjB,OAAO,WAAW;AAAA,MAClB,MAAM,oBAAoB;AAAA,MAC1B,SAAS,EAAE,cAAc,QAAQ,eAAe,MAAM;AAAA,IACxD,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/coerce/string-to-set.ts
|
|
2
|
+
import { stringToBooleanArray, stringToNumberArray, stringToStringArray } from "./string-to-array.js";
|
|
3
|
+
function stringToStringSet(stringValue, separator = ",") {
|
|
4
|
+
return new Set(stringToStringArray(stringValue, separator));
|
|
5
|
+
}
|
|
6
|
+
function stringToNumberSet(stringValue, separator = ",") {
|
|
7
|
+
return new Set(stringToNumberArray(stringValue, separator));
|
|
8
|
+
}
|
|
9
|
+
function stringToBooleanSet(stringValue, separator = ",") {
|
|
10
|
+
return new Set(stringToBooleanArray(stringValue, separator));
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
stringToBooleanSet,
|
|
14
|
+
stringToNumberSet,
|
|
15
|
+
stringToStringSet
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=string-to-set.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/coerce/string-to-set.ts"],
|
|
4
|
+
"sourcesContent": ["import { stringToBooleanArray, stringToNumberArray, stringToStringArray } from \"./string-to-array.ts\";\n\nexport function stringToStringSet(stringValue: string, separator: string = \",\"): Set<string> {\n return new Set(stringToStringArray(stringValue, separator));\n}\n\n/** @throws {CliError} - Because of `stringToNumber` */\nexport function stringToNumberSet(stringValue: string, separator: string = \",\"): Set<number> {\n return new Set(stringToNumberArray(stringValue, separator));\n}\n\n/** @throws {CliError} - Because of `stringToBoolean` */\nexport function stringToBooleanSet(stringValue: string, separator: string = \",\"): Set<boolean> {\n return new Set(stringToBooleanArray(stringValue, separator));\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,sBAAsB,qBAAqB,2BAA2B;AAExE,SAAS,kBAAkB,aAAqB,YAAoB,KAAkB;AAC3F,SAAO,IAAI,IAAI,oBAAoB,aAAa,SAAS,CAAC;AAC5D;AAGO,SAAS,kBAAkB,aAAqB,YAAoB,KAAkB;AAC3F,SAAO,IAAI,IAAI,oBAAoB,aAAa,SAAS,CAAC;AAC5D;AAGO,SAAS,mBAAmB,aAAqB,YAAoB,KAAmB;AAC7F,SAAO,IAAI,IAAI,qBAAqB,aAAa,SAAS,CAAC;AAC7D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/definitions/define-arguments.ts
|
|
2
|
+
import { prepareDefinitionTypes } from "../utilities/schema-utilities.js";
|
|
3
|
+
function defineArguments(arguments_) {
|
|
4
|
+
prepareDefinitionTypes(arguments_);
|
|
5
|
+
return arguments_;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
defineArguments
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=define-arguments.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/definitions/define-arguments.ts"],
|
|
4
|
+
"sourcesContent": ["import { prepareDefinitionTypes } from \"../utilities/schema-utilities.ts\";\n\nimport type { Argument } from \"../types/definitions-types.ts\";\n\nexport function defineArguments<const T extends Record<string, Argument>>(arguments_: {\n [K in keyof T]: T[K] & Argument<T[K][\"schema\"]>;\n}): { [K in keyof T]: Argument<T[K][\"schema\"]> } {\n prepareDefinitionTypes(arguments_);\n return arguments_;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,8BAA8B;AAIhC,SAAS,gBAA0D,YAEzB;AAC/C,yBAAuB,UAAU;AACjC,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|