Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/somucheffort/fox
A command parser library
https://github.com/somucheffort/fox
command command-parser node nodejs parser
Last synced: about 2 months ago
JSON representation
A command parser library
- Host: GitHub
- URL: https://github.com/somucheffort/fox
- Owner: somucheffort
- License: mit
- Created: 2022-11-01T15:43:46.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-01T15:44:43.000Z (about 2 years ago)
- Last Synced: 2024-11-13T13:51:39.119Z (about 2 months ago)
- Topics: command, command-parser, node, nodejs, parser
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fox
fox is a command parser library, which was introduced in [@modularium/discord](https://github.com/modularium/discord).```sh
$ npm i @sooomucheffort/fox
$ yarn add @sooomucheffort/fox
```## Example
```js
const { FoxDispatcher } = require('@sooomucheffort/fox')const fd = new FoxDispatcher()
fd.add({
base: 'ping',
info: 'pongs to you',
execute() {
return 'pong!'
}
})const [command, args] = fd.parse('ping')
fd.use(command, args)
.then(_ => console.log(_)) // pong!
.catch(e => console.log(_))
```## Example with argument parsing
```js
const { FoxDispatcher } = require('@sooomucheffort/fox')
const { KitsuneParserType } = require('@sooomucheffort/kitsune')const fd = new FoxDispatcher()
fd.add({
base: 'ping',
info: 'pongs to you',
args: [{
type: KitsuneParserType.STRING,
count: -1
}],
execute([ st ]) {
return st ? 'pong with ' + st + '!' : 'pong!'
}
})const [command, args] = fd.parse('ping abracadabra alakazam')
fd.use(command, args)
.then(_ => console.log(_)) // pong with abracadabra alakazam!
.catch(e => console.log(_))
```