bot-command-options-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Using

import CommandOptionsParser from "bot-command-options-parser/dist"

const commandOptions = [
    {
        name: "person-name",
        type: "string",
        descritpion: "Name of the person",
        required: true
    },
    {
        name: "person-age",
        type: "integer",
        descritpion: "Age of the person",
        required: true
    },
    {
        name: "person-like-minecraft",
        type: "boolean",
        descritpion: "Does the person like to play minecraft?",
        required: true
    }
]
const commandOptionsPassed = [ "Marcuth", "16.7", "true" ]

const optionsParser = new CommandOptionsParser(commandOptions)

const validateResult = optionsParser.validateOptions(commandOptionsPassed)

console.log(validateResult)

Output

[
  {
    name: 'person-name',
    type: 'string',
    values: { raw: 'Marcuth', parsed: 'marcuth' },
    isValid: { type: true, value: true }
  },
  {
    name: 'person-age',
    type: 'integer',
    values: { raw: '16.7', parsed: null },
    isValid: { type: false, value: false }
  },
  {
    name: 'person-like-minecraft',
    type: 'boolean',
    values: { raw: 'true', parsed: true },
    isValid: { type: true, value: true }
  }
]

Package Sidebar

Install

npm i bot-command-options-parser

Weekly Downloads

4

Version

1.0.5

License

MIT

Unpacked Size

30.6 kB

Total Files

34

Last publish

Collaborators

  • marcuth