Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1marcuth/bot-command-options-parser
For bots of whatsapp, guilded or telegram :D
https://github.com/1marcuth/bot-command-options-parser
Last synced: 6 days ago
JSON representation
For bots of whatsapp, guilded or telegram :D
- Host: GitHub
- URL: https://github.com/1marcuth/bot-command-options-parser
- Owner: 1Marcuth
- Created: 2023-01-02T01:37:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T22:30:25.000Z (almost 2 years ago)
- Last Synced: 2024-04-05T15:45:59.995Z (7 months ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Using
```js
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***
```js
[
{
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 }
}
]
```