https://github.com/deniz-blue/string-commands
A powerful command handler and parser for all your needs. Includes checks, custom arguments, middlewares and more.
https://github.com/deniz-blue/string-commands
command command-handler command-handlers command-line-parser command-pattern commands handler string-manipulation
Last synced: 4 months ago
JSON representation
A powerful command handler and parser for all your needs. Includes checks, custom arguments, middlewares and more.
- Host: GitHub
- URL: https://github.com/deniz-blue/string-commands
- Owner: deniz-blue
- Created: 2022-10-09T19:16:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-18T11:58:00.000Z (over 1 year ago)
- Last Synced: 2025-08-14T04:48:13.652Z (4 months ago)
- Topics: command, command-handler, command-handlers, command-line-parser, command-pattern, commands, handler, string-manipulation
- Language: JavaScript
- Homepage:
- Size: 149 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# string-commands
A powerful command handler and parser for all your needs. Includes checks, custom arguments, middlewares and more.
## Features
- Easy to use
- Recursive folder importing
- Compatability with older commands
- Configurable messages (no defaults)
- Command checks (requirements)
- Middlewares
- Argument handling with custom argument support
## Examples
For the best example please see [consoleExample.js](/examples/consoleExample.js)
## Usage
### Installing
You can install this package using
```sh
npm i string-commands
```
And then import using
```js
import { CommandHandler } from "string-commands";
```
### Documentation
See these for docs:
- [Command Handler](./docs/CommandHandler.md)
- [Commands](./docs/Commands.md)
- [Usages](./docs/Usages.md)
- [Middlewares](./docs/Middlewares.md)
## TODO
- [x] Complete typings
- [x] Middleware
- [ ] Subcommands
- [ ] Database Middlewares
- [ ] Permissions Middleware
## Changelog
**v1.1.0:**
- :warning: **BREAKING:** In `ExecutorContext` (ctx in `failedChecksMessage(ctx)`/now `on("failedChecks", (ctx)=>{})`), the **`checks`** property is now `CommandCheckResult[]` instead of `string[]`. This allows Command Checks to supply additional information about the failed checks, such as
- Codes for custom error messages
- Additional context information (for example, you could supply the user's score or something so your failed checks handler doesnt have to fetch it from a database again, or maybe supply the needed threshold etc)
- :warning: The `invalidUsageMessage` and `failedChecksMessage` functions have been removed. Please use the `invalidUsage` and `failedChecks` events instead.
- Default prefix is now `""` (empty string)
- Added [Middlewares](./docs/Middlewares.md)
- Added `index.d.ts` declarations file that's needlessly complex (and also incomplete)
- Added more documentation
**v1.0.0:**
- Created project
- Added documentation